Skip to content
Tracon

TraconMetrics

Namespace Tracon · Assembly Tracon.Core.dll

Metrics emitted by Tracon. Consumers collect them with AddMeter(TraconDiagnostics.MeterName).

public sealed class TraconMetrics : IDisposable

objectTraconMetrics

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.

TraconMetrics(IMeterFactory?, IOptionsMonitor<TraconOptions>?)

Section titled “ TraconMetrics(IMeterFactory?, IOptionsMonitor<TraconOptions>?)”

Creates a new metric set.

public TraconMetrics(IMeterFactory? meterFactory = null, IOptionsMonitor<TraconOptions>? options = null)

meterFactory IMeterFactory?

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

options IOptionsMonitor<TraconOptions>?

The root options type that TraconOptions.Observability — which carries TraconObservabilityOptions.MaxJobLaneCardinality — hangs off. When null, that setting’s own default is used. The nested type is never injected standalone: it is not registered with services.Configure<TraconObservabilityOptions> anywhere.

Agent-source failure counter. Tags: source, operation.

public Counter<long> AgentSourceFailures { get; }

Counter<long>

Job-attempt duration. Tags: lane, kind, status.

public Histogram<double> JobDuration { get; }

Histogram<double>

One measurement covers ONE attempt. A job that fails twice and then succeeds records a single measurement, for its last attempt — the earlier attempts ended in a retry, which is not a terminal status.

Finished-job counter. Tags: lane, kind, status, tenant.

public Counter<long> JobExecutions { get; }

Counter<long>

Only a TERMINAL status is counted. A lease renewal or a release for retry is not an outcome, and counting it would turn this instrument’s meaning from “how many jobs finished” into “how many things happened”.

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>

Response-cache lookup counter. Tags: provider, tenant, result (hit/miss).

public Counter<long> ModelCacheLookups { get; }

Counter<long>

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()

Records an agent-source failure or contract violation.

public void RecordAgentSourceFailure(string sourceName, string operation)

sourceName string

The source name.

operation string

The operation: list, resolve, or consistency.

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.

RecordJob(string, string, JobStatus, string?, TimeSpan)

Section titled “ RecordJob(string, string, JobStatus, string?, TimeSpan)”

Records a background job that reached a terminal status.

public void RecordJob(string lane, string handlerKey, JobStatus status, string? tenantId, TimeSpan duration)

lane string

The job’s lane (JobRecord.Lane). Guarded against runaway cardinality: see TraconObservabilityOptions.MaxJobLaneCardinality.

handlerKey string

The job’s handler key (JobRecord.HandlerKey).

status JobStatus

The terminal status: JobStatus.Completed, JobStatus.Failed, or JobStatus.Cancelled.

tenantId string?

The tenant the job belongs to. "unknown" is written when null.

duration TimeSpan

How long THIS attempt took, measured on a monotonic clock. It is not the job’s total time across every attempt.

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, double)

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

Records the score given by a judge.

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

judgeName string

The judge’s name (IRunJudge.Name).

agentName string

Name of the scored agent.

tenantId string

Tenant identifier.

score double

Score, 0-100.

RecordModelCacheLookup(string, string, bool)

Section titled “ RecordModelCacheLookup(string, string, bool)”

Records a response-cache lookup.

public void RecordModelCacheLookup(string provider, string tenantId, bool hit)

provider string

Model provider name.

tenantId string

Tenant identifier.

hit bool

Whether the lookup found a cached response.

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 TraconObservabilityOptions.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.