-
Notifications
You must be signed in to change notification settings - Fork 566
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
config: Add WithPrometheusRegisterer
config option
#6091
Conversation
This is to allow the OTel Collector to configure its own handler for prometheus metrics, allowing it to manage error reporting and shutdown. Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6091 +/- ##
=======================================
- Coverage 65.7% 65.6% -0.1%
=======================================
Files 203 203
Lines 13037 13045 +8
=======================================
Hits 8568 8568
- Misses 4206 4213 +7
- Partials 263 264 +1
|
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
WithRegistry
config optionWithPrometheusRegisterer
config option
@@ -127,6 +129,17 @@ func WithOpenTelemetryConfiguration(cfg OpenTelemetryConfiguration) Configuratio | |||
}) | |||
} | |||
|
|||
// WithPrometheusRegisterer sets a Prometheus registerer to be used by | |||
// any Prometheus exporters configured in this SDK. Note: if this option | |||
// is set, the caller is expected to initialize their own handler to |
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.
Can you help explain this a bit more to me? Doesn't this mean most of the prometheus configuration provided via config (e.g. port, path) is ignored? Why does the collector need this behavior?
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.
So the bulk of the prometheus handler code in the collector exists here: https://github.com/open-telemetry/opentelemetry-collector/blob/e99074da2f6525cd177f26b46b8d03fef2fe4f35/service/internal/proctelemetry/config.go#L106-L116
I'm totally open to suggestions as to a better way to implement this, the problem I was trying to solve was handling errors without passing a channel around.
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 wonder if we should use the otel error handler for the async errors from this package: https://github.com/open-telemetry/opentelemetry-go/blob/29c0c28a2c13f898c8245250aab8f5f336250a91/handler.go#L33. Then also handle those errors generally in the collector however you see fit? What do you do with async errors you get back?
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.
So the error channel used terminates the collector on error:
// AsyncErrorChannel is the channel that is used to report fatal errors.
AsyncErrorChannel chan error
I suppose we could register an error handler and set it to return the error to the channel instead?
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'll try to implement that and see how far i can get. will put this in draft until I get that working
Closing, this option is not required as using the otel handler can provide the functionality the collector needed |
This is to allow the OTel Collector to configure its own handler for prometheus metrics, allowing it to manage error reporting and shutdown.
I'm opening this PR to get feedback from contributors on whether this approach makes sense or not, will add tests once I get some feedback.