You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a slog.Logger using nrslog.WithTransactionFromContext transaction contexts stops being propagated after calling With on the resulting logger. This is because TransactionFromContextHandler does not implement its own WithAttrs and WithGroup functions which means they are delegated to the underlying NRHandler. Thus TransactionFromContextHandler is removed from the handler stack after calling either of these functions.
Steps to Reproduce
handler:=nrslog.TextHandler(app, os.Stdout, &slog.HandlerOptions{})
logger:=slog.New(nrslog.WithTransactionFromContext(handler))
appLogger:=logger.With(slog.String("component", "app"))
tx:=app.StartTransaction("test")
ctx:=newrelic.NewContext(context.Background(), tx)
logger.InfoContext(ctx, "has transaction context")
appLogger.InfoContext(ctx, "does not have transaction context")
Expected Behavior
Transaction context is propagated after using slog.With.
NR Diag results
Your Environment
Reproduction case
Additional context
The text was updated successfully, but these errors were encountered:
Description
When creating a
slog.Logger
usingnrslog.WithTransactionFromContext
transaction contexts stops being propagated after callingWith
on the resulting logger. This is becauseTransactionFromContextHandler
does not implement its ownWithAttrs
andWithGroup
functions which means they are delegated to the underlyingNRHandler
. ThusTransactionFromContextHandler
is removed from the handler stack after calling either of these functions.Steps to Reproduce
Expected Behavior
Transaction context is propagated after using
slog.With
.NR Diag results
Your Environment
Reproduction case
Additional context
The text was updated successfully, but these errors were encountered: