Skip to content

AgentFrameworkMetricsOptions

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework.Diagnostics

AgentFrameworkMetricsOptions Class

Configuration options for the agent framework's OpenTelemetry metrics and tracing.

public sealed class AgentFrameworkMetricsOptions

Inheritance System.Object 🡒 AgentFrameworkMetricsOptions

Remarks

Consumers that have existing dashboards keyed to a specific meter name (e.g., "BrandGhost.Agents") can set MeterName to match, avoiding a dashboard migration when adopting Needlr's IAgentMetrics.

Configure via the syringe:

.UsingAgentFramework(af => af
    .ConfigureMetrics(o => o.MeterName = "MyApp.Agents"))

Properties

AgentFrameworkMetricsOptions.ActivitySourceName Property

The name used for the System.Diagnostics.ActivitySource that emits distributed tracing spans. Defaults to MeterName when null.

public string? ActivitySourceName { get; set; }

Property Value

System.String

AgentFrameworkMetricsOptions.ChatCompletionActivityMode Property

Controls how Needlr's diagnostics middleware creates System.Diagnostics.Activity spans for chat completion calls.

public NexusLabs.Needlr.AgentFramework.Diagnostics.ChatCompletionActivityMode ChatCompletionActivityMode { get; set; }

Property Value

ChatCompletionActivityMode

Remarks

When MEAI's UseOpenTelemetry() or MAF's WithOpenTelemetry() is also active, both Needlr and the upstream middleware create spans for the same chat completion call. Set this to EnrichParent to avoid duplicate spans — Needlr will add its tags (sequence number, char counts, agent name) to the existing parent gen_ai.* activity instead of creating a new one.

Tool call activities (agent.tool) are not affected by this setting — they are always created because neither MEAI nor MAF produces per-tool-call spans.

AgentFrameworkMetricsOptions.MeterName Property

The name used for the System.Diagnostics.Metrics.Meter that emits counters and histograms. Defaults to "NexusLabs.Needlr.AgentFramework".

public string MeterName { get; set; }

Property Value

System.String