open-telemetry / opentelemetry-java-contrib

https://opentelemetry.io
Apache License 2.0
163 stars 129 forks source link

X-Ray formatted trace ID injection #148

Open willarmiros opened 2 years ago

willarmiros commented 2 years ago

Is your feature request related to a problem? Please describe. I would like to be able to instrument common logging libraries like Log4J and Logback to inject trace IDs that are formatted in the AWS X-Ray format, as opposed to the default W3C format.

Describe the solution you'd like This solution is already available in the downstream AWS-distributed Java agent (source). I would like a similar library instrumentation available so I can use it without needing the agent.

Describe alternatives you've considered Injecting trace IDs in W3C format works for manual trace -> log correlation, but for automated correlation done by AWS services like ServiceLens, the X-Ray format is required.

cc @anuraaga

trask commented 1 year ago

hey @willarmiros, have you seen https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/log4j/log4j-appender-2.17/library and https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/logback/logback-appender-1.0/library?

anuraaga commented 1 year ago

I think this is more about context data, which gets a fixed formatting here

https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/log4j/contextdata/v2_17/OpenTelemetryContextDataProvider.java#L40

Perhaps the propagator can be used instead of fixed key/values there