-
Notifications
You must be signed in to change notification settings - Fork 7
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
Remove provider configuration from HttpMetricsLayerBuilder
.
#150
Conversation
thanks, the changes LGTM However, as you can see, the build part of the global provider actually contains quite a lot of code. In other words, this crate also serves partly to simplify the initialization of the global provider in the app. I wonder if this part could perhaps be separated into a helper crate? |
I'm not sure how much the provider specific init logic belongs in any particular crate per se. That being said, those examples could be provided as part of the crate, perhaps in an Skimming through the current impl, the two main pieces of extra logic beyond using otel API directly are:
|
Using examples is certainly good. However, as a document, it might be better because what everyone sees at first glance is likely the document, rather than searching for examples. I think we can merge this first, and the document can be submitted as another PR. |
To preface the below proposal, thank you for this library! It already helps immensely to instrument axum servers.
This PR stems from a fork I had to create to reduce responsibility of the library and make it suitable for a personal project.
As-is, the
HttpMetricsLayerBuilder::new().build()
function implicitly sets the global meter provider:axum-otel-metrics/src/lib.rs
Line 329 in 21aee4e
This feels vastly out of scope of a middleware and complicates a number of concerns:
HttpMetricsLayerBuilder
API has to do with indirectly configuring the provider, instead of setting up the metrics layer.HttpMetricsLayerBuilder
has to account for generics to support customopentelemetry_sdk::metrics::reader::MetricReader
.I suspect this design choice stems from convenience for minimal applications and probably supports a majority of dependents.
However, I can't help but find this blurry separation of concerns detrimental to wider adoption.
As per
opentelemetry
crate Global Metrics API:This library seems to fall squarely within the intended usage of the
global
API.The added value of ease of use for users could be achieved through documentation, rather than implicit configuration within the library. WDYT?