feat(extensions): pass log infos explicitly instead of via context (#334) - #335
Merged
Merged
Conversation
) Generated controllers now attach the contextual values (channel, correlation ID, direction, provider, broker message, version) to every logger call as explicit LogInfo arguments, sourced from extensions.LogInfosFromContext. The built-in Text and ECS loggers drop their context-enrichment (setInfoFromContext) and log only what they are given. The values are still stored in the context, so custom loggers that want to keep reading from it can still call LogInfosFromContext. BREAKING CHANGE: the built-in Text/ECS loggers now emit the generic LogInfosFromContext keys (channel, correlationID, brokerMessage, direction, provider, version) instead of their previous custom names (e.g. ECS no longer maps to trace.id, event.action, event.original). Closes #334 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #334. Follow-up to #133 / #331 — completes the breaking part.
What
Stop relying on the
context.Contextto carry logging metadata into the loggers.c.logger.Info/Warning/Error(...)call now attaches the contextual values explicitly viaextensions.LogInfosFromContext(ctx).... The single call site that already passes extra info usesappend(extensions.LogInfosFromContext(ctx), …)....Text,ECS): droppedsetInfoFromContext; they no longer read from the context and log only what they are given (plus the intrinsicmessage/@timestamp/log.*keys).Design decision
LogInfosFromContextemits generic keys (channel,correlationID,brokerMessage,direction,provider,version) and is the single source of truth. The loggers are now pure pass-through: they print those generic keys rather than re-mapping them.Scope / acceptance
LogInfos explicitly at each log call.TextandECSloggers no longer callsetInfoFromContext.*.gen.go); examples updated.Testing
go build ./...,go vet ./...cleango test ./pkg/codegen/... ./pkg/extensions/...pass (broker integration tests requiring a live NATS server are excluded — unrelated)golangci-lintclean on changed packages and sample generated code🤖 Generated with Claude Code