Skip to content

OpenTelemetryAgentDecorator

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Wraps every agent resolved from the catalog with Microsoft Agent Framework’s AI.OpenTelemetryAgent decorator.

public sealed class OpenTelemetryAgentDecorator : IAgentDecorator

objectOpenTelemetryAgentDecorator

IAgentDecorator

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

OpenTelemetryAgentDecorator.Order is 10. It is outside RunRecordingAgentDecorator at 0 and inside tool approval at 20. The generated invoke_agent span is therefore a child of agentprism.run, and the waterfall view shows the right hierarchy.

Passes autoWireChatClient: false. The chat client pipeline already uses UseOpenTelemetry(AgentPrismDiagnostics.ActivitySourceName). See OpenAIChatClientFactory. Automatic wiring would wrap the same client twice and produce duplicate spans for each model call.

OpenTelemetryAgentDecorator(IOptions<AgentPrismOptions>)

Section titled “ OpenTelemetryAgentDecorator(IOptions<AgentPrismOptions>)”

Initializes a new telemetry decorator.

public OpenTelemetryAgentDecorator(IOptions<AgentPrismOptions> options)

options IOptions<AgentPrismOptions>

The AgentPrism options.

ArgumentNullException

options is null.

Gets the order of application. A lower value wraps inside, a higher value wraps outside. Run recording uses 0, which makes it the outermost decorator.

public int Order { get; }

int

Decorates the agent.

public AIAgent Decorate(AIAgent agent, AgentDescriptor descriptor)

agent AIAgent

The agent to decorate.

descriptor AgentDescriptor

The catalog summary of the agent.

AIAgent

The decorated agent.