Make context available in log record processor onEmit #2927
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.
Context
is not available toLogRecordProcessor#onEmit
implementations 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#onEmit
is 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
onEmit
with an additional argument,Context
.An alternative I considered was making
Context
accessible onReadWriteLogRecord
. This is a worse design because it causes references toContext
to have to be held on longer inBatchLogRecordProcessor
implementations.