-
Notifications
You must be signed in to change notification settings - Fork 576
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
otellogr emits nil context causing panic in exporters #6509
Comments
cc @scorpionknifes @pellared as code owners. |
Because there is no default opentelemetry-go-contrib/bridges/otellogr/logsink.go Lines 173 to 179 in 13b1cc5
In addition, the opentelemetry-go-contrib/bridges/otellogr/logsink.go Lines 204 to 206 in 13b1cc5
|
If the context is mandatory, should we require it as a mandatory parameter? otellogr.NewLogSink(ctx, "example", otellogr.WithLoggerProvider(provider)) |
There is another way to allow
ctx, span := otel.Tracer("example").Start(context.Background(), "example")
defer span.End()
sink := otellogr.NewLogSink("example", otellogr.WithLoggerProvider(provider))
sink.WithContext(ctx).Info(".....") |
I found some information, but I'm not sure if this discussion applies. |
If there is no one to deal with this problem, I can help deal with it. |
I'm not certain what's the best way forward here. I would prefer returning a context.Background() instead of init it with a default context. As defaulting it with a context may incentivise users to pass in a context from a trace that won't be related to the log line that does not have ctx passed in. |
I will handle it as follows. Do you have any good suggestions?
|
Description
By default, otellogr emits logs with a nil context - this causes exporters that do not support nil contexts to panic.
This happens because it uses a context that is never initialised
Environment
go.opentelemetry.io/contrib/bridges/otellogr v0.8.0
Steps To Reproduce
Run the following code:
Results in
Expected behavior
Using otellogr should not cause panics.
Workaround
Its possible to work around this problem by passing a context via WithValues
The text was updated successfully, but these errors were encountered: