fix(opentelemetry-instrumentation-logging): Promote otel.event.name to LogRecord.event_name in _translate#4864
Open
rads-1996 wants to merge 3 commits into
Conversation
otel.event.name to LogRecord.event_name in _translateotel.event.name to LogRecord.event_name in _translate
rads-1996
force-pushed
the
promote-event-name-in-logging-handler
branch
from
July 24, 2026 17:21
8aabcf8 to
1313f61
Compare
rads-1996
marked this pull request as ready for review
July 24, 2026 17:27
…ent_name in _translate
rads-1996
force-pushed
the
promote-event-name-in-logging-handler
branch
from
July 24, 2026 18:46
1313f61 to
f479990
Compare
lmolkova
approved these changes
Jul 24, 2026
emdneto
reviewed
Jul 24, 2026
| from opentelemetry.semconv._incubating.attributes import code_attributes | ||
| from opentelemetry.semconv.attributes import exception_attributes | ||
| from opentelemetry.semconv._incubating.attributes import ( | ||
| code_attributes, |
Member
There was a problem hiding this comment.
I think code_attributes are already stable no?
Contributor
Author
There was a problem hiding this comment.
https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/code_attributes.py, it exists both in the stable and experimental folder. I can change the import to import from stable path. This attribute was already being imported. Not part of this change.
emdneto
reviewed
Jul 24, 2026
| # Both keys are always popped so neither leaks into attributes. | ||
| event_name: str | None = attributes.pop( | ||
| otel_attributes.OTEL_EVENT_NAME, None | ||
| ) |
Member
There was a problem hiding this comment.
can you leave a todo comment to remove the deprecated branch path before making the package stable?
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.
Description
Ported over from #4750
LoggingHandler._translatenever set the first-classevent_namefield onLogRecord. When a user passed otel.event.name (or the deprecated event.name)via extra={...}, it silently landed in attributes as a plain key and was
exported as a regular OTLP attribute instead of the dedicated event_name field.
This fix updates
_get_attributesto pop both keys from the attributes dict andreturn the resolved event name alongside the attributes. _translate then passes
it as event_name= to LogRecord(...).
otel.event.name(stable) takes precedenceevent.name(deprecated) is used only as a fallbackBoth keys are always popped so neither leaks into attributes
Fixes #4743
Part of open-telemetry/community#1751
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.