Repository navigation
[Bug]: tracing appender exports the synthesized event <file>:<line> name as EventName #3797
Description
What happened?
OpenTelemetryTracingBridge sets EventName from Metadata::name() for every tracing event since #1928. When the call site gives no name:, which is the case for almost every info/warn/error in practice, tracing macros synthesize one: concat!("event ", file!(), ":", line!()). That synthesized name ends up on the wire as the OTLP EventName:
{
"body": { "message": "Created OTEL service" },
"event_name": "event crates/api/otel_client.rs:707",
"scope_name": "kubernetes::deployer",
"severity_text": "INFO",
...
}The crate documents this as intended ("every tracing Event is actually an OTel Event", lib.rs mapping table). I think that mapping is wrong for synthesized names:
- In the logs data model,
EventNameidentifies the class/type of an event and implies a stable structure that consumers can route, filter or alert on. A record with a non-emptyEventNameis an Event; one without is a log. event <file>:<line>identifies a source location, not a class of event. It changes whenever a line is added above the call site, so the same occurrence gets a different "event type" in every release. Nobody chose it, so nobody maintains it as a contract.- As a result, every plain log emitted through
tracingis exported as an Event. Backends that treatEventNameas an event type (indexing, grouping, event-specific pipelines) get one event type per call site per build. - It also leaks the source tree layout into telemetry by default.
The source location is still useful, but it already has a home: the code.* attributes (experimental_metadata_attributes).
Expected: set EventName only when the name was given explicitly (error!(name: "my-event", ...)), and leave it unset for the synthesized event <file>:<line> name, so those records are exported as logs. The bridge still has the Metadata, so this can be decided exactly, without heuristics: the name is synthesized if it equals "event " + meta.file() + ":" + meta.line(), which can be checked without allocating. Logger::event_enabled would then receive None for those records, consistently with what gets exported.
OpenTelemetry API Version (i.e version of opentelemetry crate)
0.32.0 (also reproduced on main)
OpenTelemetry SDK Version (i.e version of opentelemetry_sdk crate)
0.32.1 (also reproduced on main)
What Exporter(s) are you seeing the problem on?
OTLP
Relevant log output
event_name: "event crates/api/kubernetes/src/deployer/otel_client.rs:707"
Activity
fix(appender-tracing): don't export synthesized event names as EventName