fix(sdk): use context instead of deprecated trace_id/span_id kwargs in EventLogger.emit#5199
Open
kimjune01 wants to merge 1 commit into
Open
Conversation
…tLogger.emit EventLogger.emit() was constructing LogRecord with explicit trace_id, span_id, and trace_flags parameters, which triggers a deprecation warning since 1.35.0. Switch to passing context to LogRecord. When the Event carries explicit trace_id/span_id/trace_flags that differ from its captured context, wrap them in a NonRecordingSpan so LogRecord picks them up from context without the deprecated kwargs. Fixes open-telemetry#4687 Assisted-by: Claude Opus 4.6
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.
Summary
EventLogger.emitpassestrace_id,span_id, andtrace_flagsdirectly toLogRecord.__init__, which triggers a deprecation warning because those keyword arguments are deprecated in favor of extracting them fromcontext.NonRecordingSpanand passes them via thecontextparameter instead.Test plan
test_event_logger_emit_explicit_trace_idsverifying that explicit trace IDs are preserved in the emitted LogRecord without triggering deprecation warningscontext=event.contextinstead of the deprecated kwargspytest opentelemetry-sdk/tests/events/test_events.py: 10 passed