opentelemetry-go icon indicating copy to clipboard operation
opentelemetry-go copied to clipboard

log: Add global LoggerProvider

Open pellared opened this issue 1 year ago • 7 comments

Problem Statement

From https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/bridge-api.md#loggerprovider

Normally, the LoggerProvider is expected to be accessed from a central place. Thus, the API SHOULD provide a way to set/register and access a global default LoggerProvider.

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.

pellared avatar Feb 26 '24 08:02 pellared

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.

MrAlias avatar Feb 26 '24 15:02 MrAlias

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.

pellared avatar Feb 28 '24 15:02 pellared

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.

MrAlias avatar Feb 28 '24 15:02 MrAlias

@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

Kimbohlovette avatar Mar 17 '24 02:03 Kimbohlovette

It is blocked until Go Logs SDK is stable.

pellared avatar Mar 17 '24 12:03 pellared

@pellared alright thanks

Kimbohlovette avatar Mar 17 '24 12:03 Kimbohlovette

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 :)

JPFrancoia avatar Sep 01 '24 13:09 JPFrancoia