def RemoteContext.from_traceparent

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

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

591# Interpret a received strict-v00 value as the sender's context. Bit 0 is
592# sampled and bit 1 is random-trace-id; the reserved bits are not interpreted
593# and do not travel with the context (law received_flags).
594def RemoteContext.from_traceparent(value: TraceParentV00) -> RemoteContext:
595  match value:
596    case TraceParentV00{trace_id, parent_id,
597      Digits.DCon{high, Digits.DCon{+low, Digits.DNil{}}}}:
598      RemoteContext{TraceId{trace_id, Hex.Digit.has_bit1(low)}, SpanId{parent_id},
599        Hex.Digit.is_odd(low)}

Uses (8)

Used by (2)