Skip to content

AgentPrismMetrics

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Metrics emitted by AgentPrism. Consumers collect them with AddMeter(AgentPrismDiagnostics.MeterName).

public sealed class AgentPrismMetrics : IDisposable

objectAgentPrismMetrics

IDisposable

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

Instruments are set up via IMeterFactory, which allows them to be isolated in tests. When the factory is not registered, a Metrics.Meter is created directly - the library does not force the consumer to call AddMetrics.

Durations are in seconds. The OpenTelemetry semantic convention mandates seconds for histogram durations; writing milliseconds would break ready-made dashboards.

Creates a new metric set.

public AgentPrismMetrics(IMeterFactory? meterFactory = null)

meterFactory IMeterFactory?

Meter factory. When null, a new Metrics.Meter instance is created and owned by this object.

Judge cost counter. Tags: judge, model, tenant, currency.

public Counter<double> JudgeCost { get; }

Counter<double>

Judge score histogram. Tags: judge, agent, tenant.

public Histogram<double> JudgeScore { get; }

Histogram<double>

Cost counter. Tags: agent, model, tenant, currency.

public Counter<double> RunCost { get; }

Counter<double>

Run duration. Tags: agent, status.

public Histogram<double> RunDuration { get; }

Histogram<double>

Run counter. Tags: agent, status, tenant.

public Counter<long> Runs { get; }

Counter<long>

Token counter. Tags: agent, model, direction.

public Counter<long> Tokens { get; }

Counter<long>

Tool call duration. Tags: tool.

public Histogram<double> ToolDuration { get; }

Histogram<double>

Tool call counter. Tags: tool, status.

public Counter<long> ToolInvocations { get; }

Counter<long>

public void Dispose()

RecordCost(string, string?, string, decimal, string)

Section titled “ RecordCost(string, string?, string, decimal, string)”

Records a run’s own cost (when a price is defined).

public void RecordCost(string agentName, string? modelId, string tenantId, decimal cost, string currency)

agentName string

Agent name.

modelId string?

Model used. When null, "unknown" is written.

tenantId string

Tenant identifier.

cost decimal

The run’s own cost (input + output). not the tree total.

currency string

Currency.

RecordJudgeCost(string, string?, string, decimal, string)

Section titled “ RecordJudgeCost(string, string?, string, decimal, string)”

Records a judge call’s own cost.

public void RecordJudgeCost(string judgeName, string? modelId, string tenantId, decimal cost, string currency)

judgeName string

The judge’s name (IRunJudge.Name).

modelId string?

The judge’s model. When null, "unknown" is written.

tenantId string

Tenant identifier.

cost decimal

The judge’s own cost (input + output).

currency string

Currency.

RecordJudgeScore(string, string, string, int)

Section titled “ RecordJudgeScore(string, string, string, int)”

Records the score given by a judge.

public void RecordJudgeScore(string judgeName, string agentName, string tenantId, int score)

judgeName string

The judge’s name (IRunJudge.Name).

agentName string

Name of the scored agent.

tenantId string

Tenant identifier.

score int

Score, 0-100.

RecordRun(string, RunStatus, string, string?, TimeSpan, RunUsage?, int?)

Section titled “ RecordRun(string, RunStatus, string, string?, TimeSpan, RunUsage?, int?)”

Records the result of a run.

public void RecordRun(string agentName, RunStatus status, string tenantId, string? modelId, TimeSpan duration, RunUsage? usage, int? agentVersion = null)

agentName string

Agent name.

status RunStatus

Final status.

tenantId string

Tenant identifier.

modelId string?

Model used.

duration TimeSpan

Run duration.

usage RunUsage?

Token usage.

agentVersion int?

The measured definition version. When null, no tag is added - either it is unknown, or the caller is already passing null because AgentPrismObservabilityOptions.IncludeAgentVersionTag is disabled.

RecordToolInvocation(string, bool, TimeSpan?)

Section titled “ RecordToolInvocation(string, bool, TimeSpan?)”

Records the result of a tool call.

public void RecordToolInvocation(string toolName, bool succeeded, TimeSpan? duration)

toolName string

Tool name.

succeeded bool

Whether the call completed successfully.

duration TimeSpan?

Call duration. null when unknown.