redpanda-data / connect

Fancy stream processing made operationally mundane
https://docs.redpanda.com/redpanda-connect/about/
8.12k stars 831 forks source link

Benthos logs should include trace_id, span_id and trace_flags when tracing is enabled #2382

Open lucasoares opened 8 months ago

lucasoares commented 8 months ago

If we have the tracing system enabled, all the application logs should include the trace_id, span_id and trace_flags as stated in Opentelemetry's specification: https://github.com/open-telemetry/opentelemetry-specification/blob/5d9cef817415a15aaa4883e184a38adec79096ed/specification/compatibility/logging_trace_context.md#overview

This is necessary to be able to correlate logs and traces.

Our log currently are non-OTLP formatted, so:

Overview

OTLP Logs Records have top level fields representing trace context. This document defines how trace context should be recorded in non-OTLP Log Formats. To summarize, the following field names should be used in legacy formats:

  • "trace_id" for TraceId, hex-encoded.
  • "span_id" for SpanId, hex-encoded.
  • "trace_flags" for trace flags, formatted according to W3C traceflags format.
lucasoares commented 8 months ago

I was looking at how to do this one...

I made a draft PR (https://github.com/benthosdev/benthos/pull/2390) only as an example of what I'm thinking... Check the description there please, I need feedback on it.