Skip to main content

current_trace_headers

Function current_trace_headers 

Source
pub fn current_trace_headers() -> Vec<(String, String)>
Expand description

The W3C trace-context headers for the current tracing span.

Returns the traceparent, and the tracestate when the span has one, as (key, value) pairs for Kafka record headers. Returns an empty Vec when there is no active span, when the span is not sampled or recorded, or when OTLP is disabled. It is always safe to call.

let span = tracing::info_span!("produce_order");
let _g = span.enter();
let carriers = krabka_trace_context::current_trace_headers();
// convert each (key, value) into your producer's Header and attach it