def SpanPlan.generate_with

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

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

1483# The local context of a span plan, from a caller's source: a span ID that
1484# excludes the plan's (SpanId.generate_with), and the context of the plan's
1485# trace ID and sampled indication with it.
1486def SpanPlan.generate_with(~S: Type, ~read: S -> IO(S & Result<&1, &1, U32 & String, U32>), source: S,
1487  plan: SpanPlan) -> IO(S & Result<&2, &2, GenerationError, LocalContext>):
1488  match plan:
1489    case SpanPlan{excluded, trace_id, sampled}:
1490      IO.bind(S & Result<&2, &2, GenerationError, SpanId>, S & Result<&2, &2, GenerationError, LocalContext>,
1491        SpanId.generate_with(~S, ~read, source, excluded),
1492        outcome => IO.pure(S & Result<&2, &2, GenerationError, LocalContext>,
1493          Draw.span_context(S, trace_id, sampled, outcome)))

Uses (13)

Used by (2)