Module rustracing_jaeger::span
source · Expand description
Span.
How to inject/extract a span
You can inject/extract the context of a span by using SpanContext::inject_to_xxx
and
SpanContext::extract_from_xxx
methods respectively.
The simplest way is to use HashMap
as the carrier as follows:
use std::collections::HashMap;
use rustracing_jaeger::span::SpanContext;
// Extraction
let mut carrier = HashMap::new();
carrier.insert(
"uber-trace-id".to_string(), // NOTE: The key must be lower-case
"6309ab92c95468edea0dc1a9772ae2dc:409423a204bc17a8:0:1".to_string(),
);
let context = SpanContext::extract_from_text_map(&carrier)?.unwrap();
let trace_id = context.state().trace_id();
assert_eq!(trace_id.to_string(), "6309ab92c95468edea0dc1a9772ae2dc");
// Injection
let mut injected_carrier = HashMap::new();
context.inject_to_text_map(&mut injected_carrier)?;
assert_eq!(injected_carrier, carrier);
References
Structs
Jaeger specific span context state.
SpanContextState
builder.Unique 128bit identifier of a trace.
Type Definitions
Candidate span for tracing.
Finished span.
Span.
Span context.
Span handle.
Span receiver.
Span reference.
Sender of finished spans to the destination channel.
Options for starting a span.