-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move initialization of component factories after flag parsing #4977
Conversation
0aef412
to
2cb708d
Compare
Codecov Report
@@ Coverage Diff @@
## main #4977 +/- ##
==========================================
+ Coverage 89.96% 90.86% +0.89%
==========================================
Files 183 181 -2
Lines 11104 10640 -464
==========================================
- Hits 9990 9668 -322
+ Misses 889 753 -136
+ Partials 225 219 -6
Continue to review full report at Codecov.
|
1271f24
to
322ea2b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the problem, and the solution is nice. I want to propose for thinking another alternative, can we only keep as our public API the Collector and let the generator deal with flags etc.? I think that way we don't have to change settings. The reason to keep only that is to separate concerns collector is a lib and builder creates the main func.
The issue i've run into is that flag parsing is done as part of Currently, So as long as completed factories is an input to the command, we will not have parsed flags prior to instantiating factories. I think options are:
|
Note: it looks like I would need to make the API change in one PR, then update the builder, and then switch to the new API in a second PR here. |
I still believe that removing "NewCommand" (this is a simple func anyway) and "NewWindowsService" from our public "offering" and let people use the builder to create the main func is a valid option. I am on PTO and will look into this more when back on 16th. |
61a0f40
to
9dd0b53
Compare
I was able to implement your suggestion above by moving NewService to the builder. One issue is that the builder integration tests pin a version of the collector (currently 0.38.0). Since this changes some functions in service (GetConfigFlag(), GetSetFlag(), Flags()), we will need to make those changes, cut a release, and then merge the rest of this PR. |
If the changes here look reasonable, i'll open a separate PR to make the changes to service flag functions |
@dashpole for me this looks right. I think as part of generating the "cmd" (via the builder) directory we should generate the |
I think the approach here is simpler, and has less of an API surface than doing the latter. I'll open the change to the public interfaces. |
Windows probably doesn't need to Reimplement the entire NewCommand. It can just perform flag parsing from the builder. |
dfa10e4
to
ffbaeb7
Compare
ffbaeb7
to
e3b5a66
Compare
This will continue to fail until it can be rebased on #5130 |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
Description:
Fixes #4967
Instead of assembling factories before creating and executing the cobra service, construct factories within the cobra run command so it happens after feature flag parsing.
Testing:
Manually tested by adding a feature gate to the OTLP receiver, and checking its value during the NewFactory() call.