data Span
An open span of the calling task. Spans nest: end them in the reverse order of opening, on the task that opened them.
When tracing is off (no OTEL_EXPORTER_OTLP_ENDPOINT) or the trace is not sampled a span is a free no-op.
Example:
use std.obs { span }
fn main() io {
let s = span.start("charge")
s.set("customer", "ann")
s.end()
print("ended")
}Output
ended
pub(api) data SpanThread safety. a span belongs to the task that opened it; end spans in the reverse order of opening.
Since. 1.0.0-beta
Methods
set | (key: str, value: str) ioAdds a string attribute. |
setInt | (key: str, value: i64) ioAdds an integer attribute. |
setError | (msg: str) ioMarks the span as failed (status ERROR) with a message. |
recording | () -> bool ioTrue when the span is recorded (sampled and exported); guard expensive attribute computation with it. |
end | () ioEnds the span. Calling it twice, or on a span that is not recorded, does nothing. |
Defined in: std/obs/obs.oxl:308