open-telemetry / opentelemetry-collector

OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
4.42k stars 1.46k forks source link

Support for exporter logging contextual information #5962

Closed mcmho closed 1 month ago

mcmho commented 2 years ago

Is your feature request related to a problem? Please describe. The problem is log messages emitted by the exporters have limited context. With thousands of signals coming from various spans and traces, logs can soon becomes very difficult to correlate.
It would be great to add contextual information, such as traceparent, traceid, span id, .., such contextual information in the log message to enrich message context.

Describe the solution you'd like For the benefit of correlating logs with better context, the solution is to add traceparent id, span id and/or trace id as part of the log message.

Potentially, we can wrap zap api like this in which it takes Context as the first parameter and any contextual information can be provided there to the logger: https://github.com/juju/zaputil/blob/ef53049637acba748be33edc4a93e51bf738b11b/zapctx/zapctx.go#L106

another similar idea: https://github.com/uptrace/opentelemetry-go-extra/tree/main/otelzap

Describe alternatives you've considered Alternately, I don't know how generic we want to make this improvement.
There is also a discussion going on zap that there are many interests to support logging contextual information: https://github.com/uber-go/zap/issues/654 Assuming a solution to the above issue can be provided timely, we can make use of this improved version of zap.

bogdandrutu commented 2 years ago

I would not invent a new logging API for the moment. Also waiting to see what logging SIG proposes.

mcmho commented 2 years ago

thanks @bogdandrutu! "logging SIG"... you are referring to uber-go/zap?