Skip to main content

parse_traceparent

Function parse_traceparent 

Source
pub fn parse_traceparent(value: &str) -> Option<TraceContext>
Expand description

Parse a W3C traceparent value: 00-{32 lowercase hex}-{16 lowercase hex}-{2 hex}.

Lenient means lenient about the CONSEQUENCE, strict about the FORMAT. An unparseable value is treated as ABSENT — None — and is never an enqueue error and never a dispatch failure. The headers stay opaque bytes to the store either way, so a malformed trace header can lose you a trace link and can never lose you a job. Both languages implement this function identically; a divergence would mean one runtime silently drops a parent the other honours.

Rejected, each for a reason W3C names:

  • a version other than 00 — this specification pins one version rather than guessing at a future one’s field layout;
  • uppercase hex — W3C mandates lowercase, and accepting both would make two producers disagree about whether two ids are the same id;
  • an all-zero trace-id or span-id — explicitly invalid in the spec;
  • any field of the wrong length, or extra/missing --separated fields.