AgentPrismMetrics
AgentPrism.Core.dllMetrics emitted by AgentPrism. Consumers collect them with
AddMeter(AgentPrismDiagnostics.MeterName).
public sealed class AgentPrismMetrics : IDisposableInheritance
Section titled “Inheritance”Implements
Section titled “Implements”Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”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.
Constructors
Section titled “Constructors”AgentPrismMetrics(IMeterFactory?)
Section titled “ AgentPrismMetrics(IMeterFactory?)”Creates a new metric set.
public AgentPrismMetrics(IMeterFactory? meterFactory = null)Parameters
Section titled “Parameters”meterFactory IMeterFactory?
Meter factory. When null, a new Metrics.Meter
instance is created and owned by this object.
Properties
Section titled “Properties”JudgeCost
Section titled “ JudgeCost”Judge cost counter. Tags: judge, model, tenant, currency.
public Counter<double> JudgeCost { get; }Property Value
Section titled “Property Value”JudgeScore
Section titled “ JudgeScore”Judge score histogram. Tags: judge, agent, tenant.
public Histogram<double> JudgeScore { get; }Property Value
Section titled “Property Value”RunCost
Section titled “ RunCost”Cost counter. Tags: agent, model, tenant, currency.
public Counter<double> RunCost { get; }Property Value
Section titled “Property Value”RunDuration
Section titled “ RunDuration”Run duration. Tags: agent, status.
public Histogram<double> RunDuration { get; }Property Value
Section titled “Property Value”Run counter. Tags: agent, status, tenant.
public Counter<long> Runs { get; }Property Value
Section titled “Property Value”Tokens
Section titled “ Tokens”Token counter. Tags: agent, model, direction.
public Counter<long> Tokens { get; }Property Value
Section titled “Property Value”ToolDuration
Section titled “ ToolDuration”Tool call duration. Tags: tool.
public Histogram<double> ToolDuration { get; }Property Value
Section titled “Property Value”ToolInvocations
Section titled “ ToolInvocations”Tool call counter. Tags: tool, status.
public Counter<long> ToolInvocations { get; }Property Value
Section titled “Property Value”Methods
Section titled “Methods”Dispose()
Section titled “ Dispose()”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)Parameters
Section titled “Parameters”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)Parameters
Section titled “Parameters”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)Parameters
Section titled “Parameters”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)Parameters
Section titled “Parameters”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)Parameters
Section titled “Parameters”toolName string
Tool name.
succeeded bool
Whether the call completed successfully.
duration TimeSpan?
Call duration. null when unknown.