Interface IHeartbeatMetricProvider
- Namespace
- Quilt4Net.Toolkit
- Assembly
- Quilt4Net.Toolkit.dll
Supplies metrics of the application's own to every heartbeat, from whatever it can reach: a queue's length, a database count, the answer of another service. Register it with AddMetricProvider<T>().
public interface IHeartbeatMetricProvider
Remarks
Resolved from dependency injection in a scope of its own for each heartbeat, so it can take any service in its constructor, a scoped one such as a database context included.
Called at each heartbeat, alongside every other provider, and given MetricTimeout to answer. The token is cancelled when the time is up or the application stops; pass it on to the calls the provider makes. A provider that throws, or does not answer in time, is logged and left out of that heartbeat; the heartbeat is still sent.
Methods
GetMetricsAsync(CancellationToken)
The metrics for this heartbeat. Names must be unique across every provider and the built-in metrics, at most 64 characters; values must be finite. A metric that breaks a rule is left out.
Task<IEnumerable<HeartbeatMetric>> GetMetricsAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancelled when the provider runs out of time, or the application stops.