pub struct OtelTracer { /* private fields */ }Expand description
A compatibility wrapper that exposes the same Tracer interface as the
OpenTelemetry SDK but is implemented internally by delegating every call
to a SzTracer.
§What this is (and is not)
This type exists so that downstream code can be written against an
“otel-style” tracer name without pulling in the real opentelemetry
crate as a dependency. It is not a real OpenTelemetry implementation:
- It does not export spans to an OTLP / Jaeger / Zipkin collector.
- v0.2.2 修复 P2-2:现已实现 W3C TraceContext
traceparentheader 传播 (00-<trace_id>-<span_id>-<trace_flags>),同时保留parent-span-idheader 以传递父 span 关系。extract优先解析 W3C,回退到 legacy。 - It does not perform sampling, baggage propagation, or context
extraction across
asyncboundaries. - Span IDs are generated from
std::collections::hash_map::RandomStaterather than per the OpenTelemetry specification (16 hex chars / 8 bytes random).
§When to use which
- Use
SzTracerdirectly for in-process span collection and W3C TraceContext header propagation. - Use
OtelTracerwhen an existing code base expects a tracer whose name signals OpenTelemetry-compatibility, but you have already decided to back it with SzTracer semantics. - For production distributed tracing across service boundaries, depend on
the real
opentelemetrySDK and use itsTracerimplementation instead.
Both SzTracer and OtelTracer satisfy the Tracer trait, so they
can be swapped at the type level without changing call sites.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OtelTracer
impl RefUnwindSafe for OtelTracer
impl Send for OtelTracer
impl Sync for OtelTracer
impl Unpin for OtelTracer
impl UnsafeUnpin for OtelTracer
impl UnwindSafe for OtelTracer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more