Configuring opentelemetry in a package #4479
Replies: 1 comment 1 reply
-
What most instrumentations do is default on the global providers, but allow overriding those values, usually using functional options. For example, the That route allows both 1 and 2 within your options. Folks don't have to worry about the providers if they don't wish to, but can do so too. As for setting custom boundaries, that's unfortunately not part of the API, but of the SDK. So it's the responsibility of the user to set the boundaries they deem reasonable (or rely on the default ones), not something doable per library. |
Beta Was this translation helpful? Give feedback.
-
I'm writing a go package that I want to instrument with opentelemetry. More specifically, I want to be able to do tracing with Jaeger and collect metrics via prometheus, but I don't want to make this decision for the users of the package. Further, if users aren't interested in either, that's fine, too.
Now I'm wondering what the best practice is to initialize opentelemetry and what configuration parameters I should expose to package users.
Some things I have considered:
MeterProvider
/TracerProvider
. The challenge I ran into is that I need to register custom views to configure custom histogram buckets. I couldn't find a way to attach those with an already initializedMeterProvider
.MeterProvider
/TracerProvider
. The user would still have to make sure to register the custom views, meh.I would appreciate some guidance here. I'm sure there are already packages that do what I'm also trying to do, so a pointer to a particularly good example would also be great.
Edit: BTW this issue isn't a bug. There just wasn't an option to ask a general question. If there's a better place to ask questions like this, feel free to redirect me.
Beta Was this translation helpful? Give feedback.
All reactions