def TraceId.generate_with

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

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

1127# A trace ID alone, from a caller's source, as an OpenTelemetry SDK generates
1128# one before its sampler decides on it. `read` returns the source's next state
1129# with each word result, and the source's final state is returned. It reads
1130# four words per candidate, most significant first, for at most eight
1131# candidates, so at most 32 words; rejects all-zero candidates and `excluded`,
1132# when there is one; and fails with SourceFailure or ExhaustedTraceId. The
1133# source is trusted to be random: the trace ID asserts random-trace-id.
1134# Laws: trace_id_tape, trace_id_failure, trace_id_candidate, trace_id_ends,
1135# trace_id_exhaustion and generated_trace_id.
1136def TraceId.generate_with(~S: Type, ~read: S -> IO(S & Result<&1, &1, U32 & String, U32>), source: S,
1137  excluded: Maybe<&2, TraceId>) -> IO(S & Result<&2, &2, GenerationError, TraceId>):
1138  +start = TraceDraw.start(excluded)
1139  Drive.finished(~TraceStep, ~TraceId, ~TraceDraw.result, ~S, Drive.read(~TraceStep, ~TraceDraw, ~TraceStep.waiting,
1140    ~TraceDraw.next, ~S, ~read, 32n, (source, (start, TraceStep.waiting(start)))))

Uses (17)

Used by (2)