Skip to content

Implement otel.event.name#16220

Merged
trask merged 8 commits intoopen-telemetry:mainfrom
trask:otel-event-name
Mar 13, 2026
Merged

Implement otel.event.name#16220
trask merged 8 commits intoopen-telemetry:mainfrom
trask:otel-event-name

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented Feb 18, 2026

otel.event.name is stable now!

The current event.name mapping is behind an experimental config option, so we can drop that in the (minor) release following the minor release where this PR lands.

@github-actions github-actions Bot added the test native This label can be applied to PRs to trigger them to run native tests label Feb 18, 2026
setAttributeOrEventName(builder, getMdcAttributeKey(key), value);
// Always capture otel.event.name as event name, taking precedence over event.name
if (context != null) {
String otelEventName = context.get("otel.event.name");
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.

MDC taking priority over explicit evenName could easily result in setting names on arbitrary logs under the context.

Would it make sense to avoid using otel.event.name from MDC at all (given it's not targeted)?

@trask trask marked this pull request as ready for review March 10, 2026 00:27
@trask trask requested a review from a team as a code owner March 10, 2026 00:27
| `otel.instrumentation.logback-appender.experimental.capture-mdc-attributes` | String | | Comma separated list of MDC attributes to capture. Use the wildcard character `*` to capture all attributes. |
| `otel.instrumentation.logback-appender.experimental.capture-event-name` | Boolean | `false` | **Deprecated.** Enable moving the `event.name` attribute (captured by one of the other mechanisms of capturing attributes) to the log event name. |

The `otel.event.name` key is supported in key-value pairs (SLF4J 2.x fluent API). When present, its value is used as the log event name and is not emitted as an attribute.
Copy link
Copy Markdown
Contributor

@laurit laurit Mar 10, 2026

Choose a reason for hiding this comment

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

Besides key-value pairs and mdc we previously also captured event name from logstash.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh, thanks! added logstash support

Copy link
Copy Markdown
Contributor

@laurit laurit left a comment

Choose a reason for hiding this comment

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

As far as I understand it will be possible to emit events only from logback. What are the users of other logging libraries supposed to do? Use otel apis? But otel logging api wasn't supposed to be used by users, has that changed?

@trask
Copy link
Copy Markdown
Member Author

trask commented Mar 10, 2026

As far as I understand it will be possible to emit events only from logback.

Also log4j2

@laurit
Copy link
Copy Markdown
Contributor

laurit commented Mar 11, 2026

As far as I understand it will be possible to emit events only from logback.

Also log4j2

I couldn't find where it would do that. I think the event name part is missing for log4j2 structured messages (didn't try, just looked at the code, maybe missed it somehow). We might need to add a test with slf4j2 structured logging and log4j logger to check what that does.

@trask
Copy link
Copy Markdown
Member Author

trask commented Mar 11, 2026

slf4j2 structured logging and log4j logger

oh, I understand now, yeah, looks like that requires supporting ThreadContext on the log4j side. and then it's hard to justify not supporting MDC, will probably go that route...

@trask trask force-pushed the otel-event-name branch from 1ade89f to b8750c2 Compare March 11, 2026 20:39
@trask trask force-pushed the otel-event-name branch 7 times, most recently from 93dceba to f0eed51 Compare March 12, 2026 03:33
@trask trask force-pushed the otel-event-name branch from f0eed51 to 682a6f6 Compare March 12, 2026 03:43
Comment on lines +214 to +215
// Event name priority (last writer wins): KVP > MDC > structured args > logstash markers
// > logger context. Sources are called in ascending priority order.
Copy link
Copy Markdown
Member Author

@trask trask Mar 12, 2026

Choose a reason for hiding this comment

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

sorry for the reordering in this method, this is why

}

@ParameterizedTest
@MethodSource("eventNameProperties")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could consider
@ValueSource(strings = {"event.name", "otel.event.name"})

// copied from EventIncubatingAttributes
private static final AttributeKey<String> EVENT_NAME = AttributeKey.stringKey("event.name");

private static final String OTEL_EVENT_NAME_KEY = "otel.event.name";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wondering whether there is also going to be a semconv constant for this? If so could consider typing it to AttributeKey<String>

@trask trask merged commit 265b5ea into open-telemetry:main Mar 13, 2026
95 checks passed
@trask trask deleted the otel-event-name branch March 13, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test native This label can be applied to PRs to trigger them to run native tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants