Skip to main content

Function: withAgentOSSpan()

withAgentOSSpan<T>(name, fn, options?): Promise<T>

Defined in: packages/agentos/src/safety/evaluation/observability/otel.ts:526

Runs fn inside a new AgentOS span and ends the span when fn settles. A rejection is recorded on the span as an exception with an error status and then rethrown. While tracing is off or content-safe telemetry is on, fn receives null, no span is made and nothing about an error is recorded.

Type Parameters​

T​

T

Parameters​

name​

string

The span's name.

fn​

(span) => Promise<T>

The work to run; it receives the span, or null.

options?​

The span's kind and attributes.

attributes?​

Attributes

kind?​

SpanKind

Returns​

Promise<T>

What fn resolves to.