-
Notifications
You must be signed in to change notification settings - Fork 246
Closed
Labels
Description
How do you use Sentry?
Sentry SaaS (sentry.io)
SDK version
0.35.3
Go version
1.25.2
Are you using Go Modules?
yes
Steps to reproduce
package logger
import (
"context"
"log/slog"
sentryslog "github.com/getsentry/sentry-go/slog"
)
func NewSentryLogger(ctx context.Context) *Logger {
handler := sentryslog.Option{
EventLevel: []slog.Level{slog.LevelError},
LogLevel: []slog.Level{slog.LevelWarn, slog.LevelInfo},
AddSource: true,
}.NewSentryHandler(ctx)
slogger := slog.New(handler)
slogger.Info("I should attach to the trace in `ctx`")Expected result
I expected from the docs that the info log would be attached to the trace in the context I provided to NewSentryHandler.
Actual result
slogger.Info creates a new context.Background(), so my log is not attached to the original trace. To do so, I would have to call slogger.InfoContext(ctx, ...) on every log. If this is intended behavior, I found the docs extremely confusing.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
No status