fix: harden typed metrics review findings

This commit is contained in:
2026-08-14 13:50:04 +03:00
parent 996a5461de
commit b7face0e94
30 changed files with 722 additions and 382 deletions
+5
View File
@@ -183,6 +183,11 @@ impl TraceContext {
&self.traceparent
}
/// Whether this context was selected for recording by the upstream/local sampler.
pub fn is_sampled(&self) -> bool {
self.traceparent.ends_with("-01")
}
pub fn tracestate_within_budget(value: &str) -> bool {
header_list_within_budget(
value,
+2
View File
@@ -55,6 +55,8 @@ fn traceparent_parser_is_strict_and_never_accepts_zero_ids() {
"0af7651916cd43dd8448eb211c80319c"
);
assert_eq!(context.traceparent(), VALID_TRACEPARENT);
assert!(context.is_sampled());
assert!(!TraceContext::generate().is_sampled());
for invalid in [
"00-00000000000000000000000000000000-b7ad6b7169203331-01",