elastic / elastic/ecs-logging-java

support for OTel APM trace_id and span_id

Aperta
#214 10 commenti 0 reazioni 0 assegnatari Vedi su GitHub
agent-java community triage
Lingua principale
Java
Stelle
148
Fork
82
Merge medio
2g 17h
PR unite (30g)
3

Descrizione

Assume you want to use the OTel APM library (for tracing) along with this ECS logging library for ECS-formatted logs (to be ingested, for example, via Filebeat). In Elasticsearch, we want correlation between OTel APM traces and app logs.

The OTel APM library (via OTel's [Logback MDC](https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/logback/logback-mdc-1.0/library)) today puts trace_id and span_id on the MDC (good), but of course today, these field names are not ECS-compliant (e.g., "trace.id" and "span.id"). To allow Elasticsearch to correlate today, we need to translate these fields either in Filebeat (Agent) or in an ingest pipeline.

One solution might be to convince OTel's Logback MDC to adopt a flexible naming convention, or [to align to ECS](https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/9390#issuecomment-1719734044).

That said, given that "trace.id" and "span.id" are first-class ECS fields, it kind of feels like the ECS logging library should explicitly handle (special case) these fields, rather than just assuming they are named correctly on the MDC (e.g., as our own APM library would do). I saw another PR that suggested [prefixing MDC field with "label" (make sense)](https://github.com/elastic/ecs-logging-java/issues/142), but that would of course further obscure trace.id and span.id.

Should we consider special handling for "trace.id" and "span.id" (always top-level), perhaps with specific code to pick these up from our own APM library (basically pass-through copy from the MDC) and from OTel (with translation from trace_id and span_id)?

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.