Table of Contents

Class AppMetrics

Namespace
Virtufin.Api.Services
Assembly
Virtufin.Api.dll

Application-level metrics for the API gateway.

public static class AppMetrics
Inheritance
AppMetrics
Inherited Members

Remarks

MeterName is what Program.cs passes to AddMeter, so the two cannot drift.

Fields

MeterName

public const string MeterName = "Virtufin.Api"

Field Value

string

ServiceName

The gateway's OpenTelemetry service, tracing source and meter name.

public const string ServiceName = "Virtufin.Api"

Field Value

string

StateChangePublishFailures

State-change notifications that failed to publish after the state write had already succeeded — i.e. events silently lost.

public static readonly Counter<long> StateChangePublishFailures

Field Value

Counter<long>

Remarks

Publication is at-most-once and not atomic with the write (see the State Change Events requirement in the pubsub-topics spec). When this fires, the write stands and no subscriber is told: there is no retry, no dead letter, and the caller sees success — correctly, since failing the call would make them repeat a write that landed.

This counter exists to answer whether that gap needs closing. Closing it means a transactional outbox, which flips the guarantee to at-least-once and makes every subscriber's idempotency a breaking concern — worth it for a daily failure, not obviously worth it for a twice-a-year one. Nobody currently knows which this is.

StateChangePublishes

State-change notifications the gateway attempted to publish, by tier.

public static readonly Counter<long> StateChangePublishes

Field Value

Counter<long>

Remarks

The denominator for StateChangePublishFailures. A failure count without it says nothing about whether the gap is rare or routine.

Tier0

Tier 0: the shared sys.api.state.saved/deleted topics (infrastructure state).

public const string Tier0 = "tier0"

Field Value

string

Tier1

Tier 1: a caller-supplied event on a caller-chosen topic (domain state).

public const string Tier1 = "tier1"

Field Value

string

Methods

RecordStateChangePublishAttempt(string, string, string)

Records an attempted state-change publish.

public static void RecordStateChangePublishAttempt(string service, string action, string tier)

Parameters

service string
action string
tier string

RecordStateChangePublishFailure(string, string, string)

Records a state-change publish that failed after a successful write.

public static void RecordStateChangePublishFailure(string service, string action, string tier)

Parameters

service string
action string
tier string