Skip to content

fix(opentelemetry-instrumentation-logging): Promote otel.event.name to LogRecord.event_name in _translate#4864

Open
rads-1996 wants to merge 3 commits into
open-telemetry:mainfrom
rads-1996:promote-event-name-in-logging-handler
Open

fix(opentelemetry-instrumentation-logging): Promote otel.event.name to LogRecord.event_name in _translate#4864
rads-1996 wants to merge 3 commits into
open-telemetry:mainfrom
rads-1996:promote-event-name-in-logging-handler

Conversation

@rads-1996

Copy link
Copy Markdown
Contributor

Description

Ported over from #4750

LoggingHandler._translate never set the first-class event_name field on
LogRecord. 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_attributes to pop both keys from the attributes dict and
return the resolved event name alongside the attributes. _translate then passes
it as event_name= to LogRecord(...).

otel.event.name (stable) takes precedence
event.name (deprecated) is used only as a fallback
Both 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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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

  • Unit tests have been added

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@rads-1996 rads-1996 changed the title fix(instrumentation-logging): Promote otel.event.name to LogRecord.event_name in _translate fix(opentelemetry-instrumentation-logging): Promote otel.event.name to LogRecord.event_name in _translate Jul 24, 2026
@rads-1996
rads-1996 force-pushed the promote-event-name-in-logging-handler branch from 8aabcf8 to 1313f61 Compare July 24, 2026 17:21
@rads-1996
rads-1996 marked this pull request as ready for review July 24, 2026 17:27
@rads-1996
rads-1996 requested a review from a team as a code owner July 24, 2026 17:27
@rads-1996
rads-1996 force-pushed the promote-event-name-in-logging-handler branch from 1313f61 to f479990 Compare July 24, 2026 18:46
@github-project-automation github-project-automation Bot moved this to Approved PRs in Python PR digest 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,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think code_attributes are already stable no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

# Both keys are always popped so neither leaks into attributes.
event_name: str | None = attributes.pop(
otel_attributes.OTEL_EVENT_NAME, None
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you leave a todo comment to remove the deprecated branch path before making the package stable?

@rads-1996
rads-1996 requested a review from emdneto July 24, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Approved PRs

Development

Successfully merging this pull request may close these issues.

Logging stability review: [minor] otel.event.name not promoted to the EventName by logging bridge

3 participants