Function withAgentOSSpan

  • 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

    Parameters

    • name: string

      The span's name.

    • fn: ((span) => Promise<T>)

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

        • (span): Promise<T>
        • Parameters

          • span: null | Span

          Returns Promise<T>

    • Optional options: {
          kind?: SpanKind;
          attributes?: Attributes;
      }

      The span's kind and attributes.

      • Optional kind?: SpanKind
      • Optional attributes?: Attributes

    Returns Promise<T>

    What fn resolves to.