Class KevlarDiagnostics
- Namespace
- Kevlar
- Assembly
- Kevlar.dll
Names for Kevlar's built-in telemetry. On .NET 8+ targets every shield publishes counters and
duration metrics; the shipped state gauges require .NET 10 or later. Metrics are published
through a System.Diagnostics.Metrics.Meter named MeterName with zero
configuration — subscribe with AddMeter("Kevlar") (OpenTelemetry) or a
MeterListener. On netstandard2.0 the instruments are inert.
public static class KevlarDiagnostics
- Inheritance
-
KevlarDiagnostics
- Inherited Members
Remarks
The meter version is 1.0. Instruments:
kevlar.executions— completed public execution calls, including empty shields and pre-cancelled calls; attributeskevlar.shield.name,kevlar.execution.outcome(success/failure)kevlar.retries— retry attempts; attributekevlar.shield.namekevlar.timeouts— executions cancelled by a timeout strategy, including delegates that complete after ignoring cancellation; attributeskevlar.shield.nameand optionaloutcome(ignored)kevlar.hedges— extra hedged attempts launched; attributekevlar.shield.namekevlar.hedge_attempts— completed attempts within hedged executions; attributeskevlar.shield.nameandresult(won/lost/cancelled/failed)kevlar.fallbacks— outcomes replaced by a fallback; attributekevlar.shield.namekevlar.rejections— fail-fast rejections; attributeskevlar.shield.name,kevlar.rejection.type(circuit_open/rate_limit/rate_limiter_adapter/concurrency_limit)kevlar.http.replay_suppressed— HTTP requests whose configured additional attempts were disabled for replay safety; attributeskevlar.shield.nameandkevlar.suppression.reasonkevlar.circuit_breaker.transitions— circuit state changes; attributeskevlar.circuit_breaker.state.from,kevlar.circuit_breaker.state.tokevlar.callback_errors— exceptions thrown by callbacks or cleanup operations; attributeskevlar.shield.name,kevlar.callback.kind,kevlar.callback.sourcekevlar.execution.duration— execution duration histogram in seconds; attributeskevlar.shield.name,kevlar.execution.outcomekevlar.strategy.events— strategy and custom events; attributes include shield, strategy, event, severity, attempt, exception type, and an optional bounded operation keykevlar.attempt.duration— retry-attempt duration histogram in milliseconds with the strategy-event attributeskevlar.circuit_breaker.state— current state gauge (closed=0,open=1,half_open=2,isolated=3)kevlar.circuit_breaker.instances— circuit-breaker instance count grouped by current statekevlar.concurrency_limit.inflight,kevlar.concurrency_limit.queued, andkevlar.concurrency_limit.capacity— concurrency-limit state gaugeskevlar.rate_limit.availableandkevlar.rate_limit.queued— rate-limit state gauges
The kevlar.shield.name attribute is present only for shields named via WithName; an explicitly
empty name is emitted as an empty tag value. State gauges also carry the bounded
kevlar.strategy.index attribute so multiple stateful strategies in one pipeline remain distinct.
Concurrency and rate measurements with the same name and strategy index are aggregated. Use
kevlar.circuit_breaker.instances when several breakers share those attributes.
Fields
MeterName
The name of Kevlar's Meter.
public const string MeterName = "Kevlar"
Field Value
Methods
AddMetricEnricher(KevlarMetricEnricher)
Registers an application-defined enricher for every Kevlar metric measurement.
public static IDisposable AddMetricEnricher(KevlarMetricEnricher enricher)
Parameters
enricherKevlarMetricEnricherThe enricher to register.
Returns
- IDisposable
A subscription that removes the enricher when disposed.
Remarks
Enrichers run synchronously only when an enabled instrument records or observes a measurement. Enricher exceptions are ignored and do not prevent later enrichers from running. Keep tag names and values bounded to avoid unbounded metric cardinality.
Listen(IKevlarTelemetryListener)
Subscribes a listener to synchronous strategy telemetry.
public static IDisposable Listen(IKevlarTelemetryListener listener)
Parameters
listenerIKevlarTelemetryListener
Returns
- IDisposable
A subscription that removes the listener when disposed.
ReportCallbackError(CallbackErrorKind, KevlarContext, Exception, string)
Reports a callback or cleanup failure without allowing diagnostics subscribers to affect execution. Custom strategies can use this method to follow Kevlar's isolation contract.
public static void ReportCallbackError(CallbackErrorKind kind, KevlarContext context, Exception exception, string source)
Parameters
kindCallbackErrorKindThe callback family that failed.
contextKevlarContextThe active execution context.
exceptionExceptionThe exception thrown by the callback.
sourcestringA stable callback or integration identifier.
Events
OnCallbackError
Raised when a strategy notification, observer, or superseded-result disposal throws. Each subscriber is isolated: subscriber failures are swallowed and do not prevent later subscribers from running. This event is process-global, not scoped to a shield or service provider; unsubscribe handlers when their lifetime ends.
public static event Action<CallbackErrorEvent>? OnCallbackError