elastic / elastic/ecs-logging-java

support for OTel APM trace_id and span_id

Offen
#214 10 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
agent-java community triage
Vorherrschende Sprache
Java
Sterne
148
Forks
82
Ø Merge
2 T. 17 Std.
Gemergte PRs (30 T.)
3

Beschreibung

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)?

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Überprüfe zuerst die MDC-Verarbeitung der ECS logging library und das verknüpfte OpenTelemetry Logback MDC-Verhalten. Ermittle, ob für die angeforderte Übersetzung von trace_id und span_id ein festgelegtes Design existiert; abgeschlossen wäre die Aufgabe, wenn ein abgestimmter Ansatz gefunden wurde, der die Korrelation von ECS trace.id und span.id beibehält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
observability-sre
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.