Skip to content

feat(v2): pass logger to downstream via context#474

Merged
westarle merged 2 commits intogoogleapis:mainfrom
westarle:feat/callctx-withlogger
Mar 10, 2026
Merged

feat(v2): pass logger to downstream via context#474
westarle merged 2 commits intogoogleapis:mainfrom
westarle:feat/callctx-withlogger

Conversation

@westarle
Copy link
Copy Markdown
Contributor

@westarle westarle commented Mar 9, 2026

Customers set the slog logger with options.WithLogger. This change allows code to pass it further down ultimately into the transport layer to be used to log error information in production.

@westarle westarle marked this pull request as ready for review March 9, 2026 16:55
@westarle westarle requested a review from a team as a code owner March 9, 2026 16:55
@westarle westarle force-pushed the feat/callctx-withlogger branch from 4141a2a to d5ca3fa Compare March 10, 2026 15:19
@westarle westarle changed the title impl(o11y): pass logger to downstream via context feat(v2): pass logger to downstream via context Mar 10, 2026
@westarle westarle enabled auto-merge (squash) March 10, 2026 15:40
@westarle westarle merged commit 434fa67 into googleapis:main Mar 10, 2026
5 checks passed
Comment thread v2/callctx/callctx.go

// WithLogger injects a slog.Logger into the context. This logger will be
// extracted by the client library or transport wrappers to emit logs.
func WithLogger(ctx context.Context, logger *slog.Logger) context.Context {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename to WithLoggerContext to match WithTelemetryContext?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants