Make context available in log record processor onEmit#2927
Merged
reyang merged 4 commits intoopen-telemetry:mainfrom Nov 9, 2022
Merged
Make context available in log record processor onEmit#2927reyang merged 4 commits intoopen-telemetry:mainfrom
reyang merged 4 commits intoopen-telemetry:mainfrom
Conversation
reyang
reviewed
Nov 7, 2022
trask
approved these changes
Nov 8, 2022
tigrannajaryan
approved these changes
Nov 8, 2022
Member
tigrannajaryan
left a comment
There was a problem hiding this comment.
LGTM. Consistent with what we do in SpanProcessor.
25 tasks
carlosalberto
pushed a commit
to carlosalberto/opentelemetry-specification
that referenced
this pull request
Oct 31, 2024
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.
Related to #2911.
Contextis not available toLogRecordProcessor#onEmitimplementations at the moment. The API says that when emitting log records you must be able to set Trace Context, not a full Context. Accessing context inLogRecordProcessor#onEmitis important for a variety of use cases, including extracting and baggage entries as attributes on log records.Implementations have to rely on languages supporting implicit context, something like:
If implicit context is unavailable (i.e the language doesn't support it or the caller set the context explicitly) then accessing context is not possible.
This PR proposes extending
onEmitwith an additional argument,Context.An alternative I considered was making
Contextaccessible onReadWriteLogRecord. This is a worse design because it causes references toContextto have to be held on longer inBatchLogRecordProcessorimplementations.