def LocalContext.to_traceparent

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

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

664# The participating representation of a local context: version 00, and flags
665# limited to sampled (bit 0) and random-trace-id (bit 1), with every reserved
666# bit zero (W3C 3.2.2.5.3; laws emitted_traceparent and emitted_projection).
667def LocalContext.to_traceparent(context: LocalContext) -> TraceParentV00:
668  match context:
669    case LocalContext{TraceId{trace_id, random}, SpanId{span_id}, sampled}:
670      TraceParentV00{trace_id, span_id,
671        Digits.DCon{Hex.H0{}, Digits.DCon{Hex.Digit.from_bits(sampled, random, False{}, False{}), Digits.DNil{}}}}

Uses (9)

Used by (2)