GenAIMainAgentSpanProcessor class

Propagates microsoft.gen_ai.main_agent.* attributes onto spans.

  • onStart: copies main-agent attributes from the parent span (or falls back to the parent's gen_ai.agent.* / gen_ai.conversation.id attributes) onto the new span.
  • onEnd: when the span is itself an invoke_agent operation and has not already been enriched, copies its own gen_ai.agent.* / gen_ai.conversation.id attributes onto microsoft.gen_ai.main_agent.* so the top-level agent identifies itself as the main agent.

Methods

forceFlush()

Flushes pending work. No-op for this processor.

onEnd(ReadableSpan)

When a span is itself a top-level invoke_agent operation that has not already been enriched, copies its gen_ai.agent.* / gen_ai.conversation.id attributes onto the microsoft.gen_ai.main_agent.* keys.

onStart(Span, Context)

Copies main-agent attributes from the parent span (or its gen_ai.agent.* fallbacks) onto a span when it starts.

shutdown()

Shuts down the processor. No-op for this processor.

Method Details

forceFlush()

Flushes pending work. No-op for this processor.

function forceFlush(): Promise<void>

Returns

Promise<void>

onEnd(ReadableSpan)

When a span is itself a top-level invoke_agent operation that has not already been enriched, copies its gen_ai.agent.* / gen_ai.conversation.id attributes onto the microsoft.gen_ai.main_agent.* keys.

function onEnd(span: ReadableSpan)

Parameters

span

ReadableSpan

The span that has ended.

onStart(Span, Context)

Copies main-agent attributes from the parent span (or its gen_ai.agent.* fallbacks) onto a span when it starts.

function onStart(span: Span, parentContext: Context)

Parameters

span

Span

The span that is starting.

parentContext

Context

The context containing the parent span, if any.

shutdown()

Shuts down the processor. No-op for this processor.

function shutdown(): Promise<void>

Returns

Promise<void>