def TraceParentV00.format

bend-trace-context@0.2.0.0 · trace_context.bend:480

import bend-trace-context@0.2.0.0/trace_context.bend as TraceContext
import Base
import bend-trace-context@0.2.0.0/src/digits.bend as Digits

480# The text of a strict v00 value: always 55 characters. It is total, because
481# validity is carried by the argument's type, and it preserves every flag bit:
482# it is the exact inverse of parse, not an outgoing-header policy (see
483# LocalContext.to_traceparent for what a participant emits).
484def TraceParentV00.format(context: TraceParentV00) -> String:
485  match context:
486    case TraceParentV00{trace_id, parent_id, flags}:
487      "00-" ++ Digits.NonZero.to_string(32n, trace_id) ++ "-" ++
488        Digits.NonZero.to_string(16n, parent_id) ++ "-" ++
489        Digits.Digits.to_string(2n, flags)

Uses (5)

Used by (1)