[−][src]Trait tracing_opentelemetry::PreSampledTracer
An interface for authors of OpenTelemetry SDKs to build pre-sampled tracers.
The OpenTelemetry spec does not allow trace ids to be updated after a span
has been created. In order to associate extracted parent trace ids with
existing tracing
spans, tracing-opentelemetry
builds up otel span data
using a SpanBuilder
instead, and creates / exports full otel spans only
when the associated tracing
span is closed. However, in order to properly
inject otel SpanContext
information to downstream requests, the sampling
state must now be known before the otel span has been created.
The logic for coming to a sampling decision and creating an injectable span
context from a SpanBuilder
is encapsulated in the
PreSampledTracer::sampled_span_context
method and has been implemented
for the standard OpenTelemetry SDK, but this trait may be implemented by
authors of alternate OpenTelemetry SDK implementations if they wish to have
tracing
compatibility.
See the OpenTelemetrySpanExt::set_parent
and
OpenTelemetrySpanExt::context
methods for example usage.
Required methods
fn sampled_span_context(&self, builder: &mut SpanBuilder) -> SpanContext
Produce a pre-sampled span context for the given span builder.
fn new_trace_id(&self) -> TraceId
Generate a new trace id.
fn new_span_id(&self) -> SpanId
Generate a new span id.