Skip to content
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

Closed

Conversation

codeboten
Copy link
Contributor

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.

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>
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 43.75000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 65.6%. Comparing base (96fdd2e) to head (111b5b0).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
config/config.go 0.0% 5 Missing ⚠️
config/metric.go 63.6% 3 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           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     
Files with missing lines Coverage Δ
config/metric.go 90.5% <63.6%> (-1.1%) ⬇️
config/config.go 74.0% <0.0%> (-8.3%) ⬇️

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
@codeboten codeboten changed the title config: Add WithRegistry config option config: Add WithPrometheusRegisterer config option Sep 5, 2024
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
@@ -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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

@codeboten codeboten marked this pull request as draft September 6, 2024 05:02
@codeboten
Copy link
Contributor Author

Closing, this option is not required as using the otel handler can provide the functionality the collector needed

@codeboten codeboten closed this Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants