fix(sdk): use context instead of deprecated trace_id/span_id kwargs in EventLogger.emit#5199
Closed
kimjune01 wants to merge 2 commits into
Closed
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
Member
|
Thanks for the PR! Just a heads-up: we no longer update Please add the appropriate changelog fragment for this change instead of editing |
Author
Contributor
|
Hi @kimjune01 , thank you for contributing but this API itself is deprecated. I recommend picking up an issue to stabilize the new Logging API/SDK if you're interested! |
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__. Those kwargs are documented as deprecated in favor of extracting trace correlation fromcontext(the@typing_extensions.deprecatedmarkers on the relevant@overloadare type-checker-only and don't fire a runtime warning, but the API direction is upstream-documented).NonRecordingSpanand passes them via thecontextparameter — matching the supported overload going forward and removing reliance on the deprecated path.Test plan
test_event_logger_emit_explicit_trace_idsverifying that explicit trace IDs are preserved in the emitted LogRecord via thecontextpath.context=event.contextinstead of the deprecated kwargs.pytest opentelemetry-sdk/tests/events/test_events.py: 10 passed (0.31s).