#w3c #tracing #traceparent #tracestate

trace-context

提取和注入W3C TraceContext头信息

1个不稳定版本

0.1.0 2019年6月2日

#27#w3c

每月22次下载

MIT/Apache

10KB
125

trace-context

提取和注入W3C TraceContext头信息。

安装

cargo add trace-context

示例用法

let mut headers = http::HeaderMap::new();
headers.insert("traceparent", "00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01".parse().unwrap());

let context = trace_context::TraceContext::extract(&headers).unwrap();

assert_eq!(context.trace_id(), u128::from_str_radix("0af7651916cd43dd8448eb211c80319c", 16).unwrap());
assert_eq!(context.parent_id(), u64::from_str_radix("00f067aa0ba902b7", 16).ok());
assert_eq!(context.sampled(), true);

安全性

此crate使用#![deny(unsafe_code)]来确保所有内容都在100%安全的Rust中实现。

许可证

MIT OR Apache-2.0


lib.rs:

提取和注入W3C TraceContext头信息。

示例

let mut headers = http::HeaderMap::new();
headers.insert(
    "traceparent",
    "00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01".parse().unwrap()
);

let context = trace_context::TraceContext::extract(&headers).unwrap();

assert_eq!(context.trace_id(), u128::from_str_radix("0af7651916cd43dd8448eb211c80319c", 16).unwrap());
assert_eq!(context.parent_id(), u64::from_str_radix("00f067aa0ba902b7", 16).ok());
assert_eq!(context.sampled(), true);

依赖项

~1.5MB
~23K SLoC