pub struct SzTracer { /* private fields */ }Implementations§
Source§impl SzTracer
impl SzTracer
Sourcepub fn inject_legacy(&self, span: &Span) -> HashMap<String, String>
pub fn inject_legacy(&self, span: &Span) -> HashMap<String, String>
注入 legacy 自定义 header(向后兼容)
v0.2.2 修复 P2-2:保留旧版 header 格式以兼容旧客户端。
新代码应使用 Tracer::inject(W3C TraceContext)。
Sourcepub fn extract_legacy(&self, headers: &HashMap<String, String>) -> Option<Span>
pub fn extract_legacy(&self, headers: &HashMap<String, String>) -> Option<Span>
仅从 legacy header 中提取 Span(向后兼容)
v0.2.2 修复 P2-2:保留旧版 header 解析以兼容旧客户端。
新代码应使用 Tracer::extract(自动优先 W3C,回退 legacy)。
Trait Implementations§
Source§impl Tracer for SzTracer
impl Tracer for SzTracer
Source§fn inject(&self, span: &Span) -> HashMap<String, String>
fn inject(&self, span: &Span) -> HashMap<String, String>
注入 W3C TraceContext traceparent header
v0.2.2 修复 P2-2:从自定义 trace-id/span-id/parent-span-id header
升级为 W3C TraceContext 标准的 traceparent header。
格式:00-<trace_id>-<span_id>-<trace_flags>
00:版本号(W3C 规范固定为00)trace_id:32 字符 hex(16 字节)span_id:16 字符 hex(8 字节)trace_flags:2 字符 hex(01表示 sampled,00表示未采样)
同时保留 parent-span-id header 以向后兼容旧版本的 extract。
Source§fn extract(&self, headers: &HashMap<String, String>) -> Option<Span>
fn extract(&self, headers: &HashMap<String, String>) -> Option<Span>
从 headers 中提取 Span
v0.2.2 修复 P2-2:优先解析 W3C TraceContext traceparent header,
若不存在则回退到 legacy 自定义 header(trace-id/span-id)。
W3C traceparent 格式:00-<trace_id>-<span_id>-<trace_flags>
- 版本号必须为
00 - trace_id 必须为 32 字符 hex
- span_id 必须为 16 字符 hex
- trace_flags 必须为 2 字符 hex
fn start_span(&self, operation_name: &str) -> Span
fn end_span(&self, span: Span)
Auto Trait Implementations§
impl Freeze for SzTracer
impl RefUnwindSafe for SzTracer
impl Send for SzTracer
impl Sync for SzTracer
impl Unpin for SzTracer
impl UnsafeUnpin for SzTracer
impl UnwindSafe for SzTracer
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