-
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
Allow running service.Collector without CLI interface #3957
Comments
Related to #3843 |
@mx-psi the configuration related flags, are just flags that allow to overwrite any property in the config, so they cannot and don't have to be removed since obviously everything can be configured in the config :) |
@bogdandrutu My point with this issue is that the CLI code is not separate from the rest of the code. Right now, if you call For some of the flags above, the solution is to remove them, but for the ones that can't be removed, the solution is to provide a way to not run the CLI parsing. Does that make sense? Is that a use case that the Collector should support? |
@mx-psi tell me more how do you envision to support the second part? |
@bogdandrutu One way to support that would be to have an intermediate struct, say type Application struct {
// same thing as service.Collector now, without the cobra/flags bits
}
type ApplicationSettings struct {
// all of CollectorSettings fields go here
// ...
OverrideFlags map[string]interface{} // the --set flag value
MetricsLevel configtelemetry.Level // the --metrics-level value
// ... other flag values
} and then the Maybe the configuration flags in particular do not even have to be in |
@bogdandrutu are there other PRs related to this issue in the pipeline? |
@bogdandrutu is this issue done? :-) |
@alolita see tracking items in the issue description. |
Is your feature request related to a problem? Please describe.
The public API of
service.Collector
allows for the creation of different distros easily, which can customize the components included, logging, and configuration among other aspects, and it provides a common CLI through theCommand
method. However, there is no way to customize or disable the CLI interface or customize the values of the CLI flags exposed hereopentelemetry-collector/service/collector.go
Lines 148 to 156 in 4ecdfce
This makes it harder to embed the Collector in an existing binary application and expose its functionality in an uniform way.
Describe the solution you'd like
The Collector (or some other intermediate public struct) allows setting all configuration through either the config parser or a configuration struct like
service.CollectorSettings
, while keeping the existing option to parse CLI flags as a separate step. This would involve (at least) the following flags parsing to be refactored:Describe alternatives you've considered
You can use the
Run
method and use the default values for the non-exposed configuration.Additional context
This relates broadly to the goals on #3482.
The text was updated successfully, but these errors were encountered: