Sign in

    moonbitstack/moonzero/trace does not have a README file

    TraceContext

    pub(all) struct TraceContext {
    trace_id : String
    span_id : String
    flags : Int
    }

    A W3C Trace Context (← go-zero's OpenTelemetry propagation): the 128-bit trace id shared across a request's whole call tree, the 64-bit span id of the current hop, and the 8-bit sampling flags.

    TraceContext::span_id

    fn TraceContext::span_id(self : TraceContext) -> String

    The span id of this hop.

    TraceContext::to_traceparent

    fn TraceContext::to_traceparent(self : TraceContext) -> String

    Format as a W3C traceparent header value: 00-<32 hex trace-id>-<16 hex span-id>-<2 hex flags>.

    TraceContext::trace_id

    fn TraceContext::trace_id(self : TraceContext) -> String

    The trace id (the value propagated unchanged down the call tree).

    generate_span_id

    fn generate_span_id(seed : Int64) -> String

    A 16-hex-char (64-bit) span id from seed.

    generate_trace_id

    fn generate_trace_id(seed : Int64) -> String

    A 32-hex-char (128-bit) trace id from seed, mixing two independent words.

    next_trace_context

    fn next_trace_context(inbound : String?, seed : Int64) -> TraceContext

    Derive the outgoing trace context for a request: reuse the inbound traceparent's trace id if the client sent a valid one (continuing the distributed trace), else start a new trace, and always mint a fresh child span id from seed. This is the propagation decision, pulled out as a pure function so it is testable without the transport.

    parse_traceparent

    fn parse_traceparent(value : String) -> TraceContext?

    Parse a W3C traceparent value, or None if it is malformed. Only the four canonical fields with correct lengths are accepted; the flags default to 0 if unparseable.

    Source Files