opentelemetry-go
opentelemetry-go copied to clipboard
log: Add global LoggerProvider
Problem Statement
From https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/bridge-api.md#loggerprovider
Normally, the
LoggerProvideris expected to be accessed from a central place. Thus, the API SHOULD provide a way to set/register and access a global defaultLoggerProvider.
Proposed Solution
Add GetLoggerProvider and SetLoggerProvider to go.opentelemetry.io/otel.
Notice that this can be released only when Bridge API gets stable as go.opentelemetry.io/otel is already stable.
We cannot add support for this to otel until log is stable. If we want to support this prior to 1.0 a similar approach to https://pkg.go.dev/go.opentelemetry.io/otel/metric/global should be used.
If we want to support this prior to 1.0 a similar approach to https://pkg.go.dev/go.opentelemetry.io/otel/metric/global should be used.
Do you think that it is worth doing it prior 1.0? It may be inconvenient as otherwise we will make a breaking change when going stable. I would rather add it even in "1.1" as this is not a MUST in the specification and adding after the API is already stable would be more gentle for the users. This change would not affect the SDK.
I'm fine with a post-1.0. I think the metric one was motivated by a user ask and our desire to build a proof-of-concept for how it would work. I don't know of any user ask for this, currently, and I think the global implementation will be one of the easier ones.
@pellared could you please assign this task to me? @jpkrohling could I peak this one? It directly related to the project "Implement one Logging bridge" in outreachy-otel
It is blocked until Go Logs SDK is stable.
@pellared alright thanks
It took me a while to figure out I could do that: https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp#example-package
Since the SetLoggerProvider isn't in otel's index, it's not easily discoverable. I'm already setting the tracer and provider with Set*Provider, can't wait for the logger one :)