OxL Справочник OxL
РусскийEnglish

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:

oxl✓ проверяется в CI
use std.obs { span }

fn main() io {
  let s = span.start("charge")
  s.set("customer", "ann")
  s.end()
  print("ended")
}
Вывод
ended
pub(api) data Span

Потокобезопасность. a span belongs to the task that opened it; end spans in the reverse order of opening.

С версии. 1.0.0-beta

Методы

set(key: str, value: str) io
Adds a string attribute.
setInt(key: str, value: i64) io
Adds an integer attribute.
setError(msg: str) io
Marks the span as failed (status ERROR) with a message.
recording() -> bool io
True when the span is recorded (sampled and exported); guard expensive attribute computation with it.
end() io
Ends the span. Calling it twice, or on a span that is not recorded, does nothing.

Определено в: std/obs/obs.oxl:308

См. также