Class HeartbeatReportingOptions
- Namespace
- Quilt4Net.Toolkit
- Assembly
- Quilt4Net.Toolkit.dll
Options for reporting heartbeats with capabilities to Quilt4Net.
public record HeartbeatReportingOptions : IEquatable<HeartbeatReportingOptions>
- Inheritance
-
HeartbeatReportingOptions
- Implements
- Inherited Members
Remarks
Not the Application Insights heartbeat in Quilt4Net.Toolkit.Health
(Quilt4Net:HealthApi:Heartbeat). That one sends availability telemetry; this one tells
Quilt4Net which capabilities this instance has, so a rule there can raise an alarm when a
capability goes silent.
Fields
MaxCustomMetrics
The most metrics of the application's own: with the four built-in ones, Quilt4Net takes at most 20.
public const int MaxCustomMetrics = 16
Field Value
Properties
ApiKey
Team API key used for every call. Reporting needs heartbeat:write, which an ordinary
application key has.
public string ApiKey { get; set; }
Property Value
Application
Application name to report. When not set, the entry assembly's name is used.
public string Application { get; set; }
Property Value
Capabilities
What this instance can do, such as import or export. A rule on Quilt4Net names
a capability and alarms when no instance with it has reported in time.
public string[] Capabilities { get; set; }
Property Value
- string[]
Cpu
Which processor use each heartbeat reports, as a percentage of all cores. Default is Process: this application's own use, the same on every platform. Set None to send none.
public CpuMetric Cpu { get; set; }
Property Value
Enabled
Whether to report at all. Default is true. Set false in configuration to keep the registration in code but stop reporting on a machine or in an environment, such as a developer's laptop that would otherwise count as a live instance.
public bool Enabled { get; set; }
Property Value
Environment
Environment name to report. When not set, the host environment's name is used.
public string Environment { get; set; }
Property Value
Instance
Instance name to report, which tells two copies of the application apart. When not set, the machine name is used.
public string Instance { get; set; }
Property Value
Interval
How often to report. Default is 5 minutes. A rule's silence window should be a few intervals, so one late report does not raise an alarm.
public TimeSpan Interval { get; set; }
Property Value
Memory
Which memory use each heartbeat reports, in percent of the memory available to the process (the machine's, or the container's limit). Default is Process: this application's own. Set None to send none.
public MemoryMetric Memory { get; set; }
Property Value
MetricTimeout
How long the application's own metrics may take at each heartbeat, every IHeartbeatMetricProvider and AddMetric(string, Func<double>, string) at once. Default is 10 seconds. One that is later is left out of that heartbeat.
public TimeSpan MetricTimeout { get; set; }
Property Value
Quilt4NetAddress
Address of the Quilt4Net server. Defaulted on the type so an unbound
IOptions<HeartbeatReportingOptions> still carries a usable URL.
public string Quilt4NetAddress { get; set; }
Property Value
Methods
AddMetric(string, Func<double>, string)
Adds a value of the application's own to every heartbeat, such as a queue's length. Read on each heartbeat; a read that throws is logged and left out of that heartbeat, never stopping it.
public HeartbeatReportingOptions AddMetric(string name, Func<double> value, string unit = null)
Parameters
namestringUnique, at most 64 characters, such as
queue.length.valueFunc<double>Reads the value.
unitstringWhat it counts, such as
percentoritems; the graph's axis label. Optional.
Returns
Exceptions
- ArgumentException
The name is empty, too long, taken or built in, or there are too many.
AddMetric(string, Func<CancellationToken, Task<double>>, string)
Adds a value of the application's own to every heartbeat, such as a queue's length. Read on each heartbeat; a read that throws is logged and left out of that heartbeat, never stopping it.
public HeartbeatReportingOptions AddMetric(string name, Func<CancellationToken, Task<double>> value, string unit = null)
Parameters
namestringUnique, at most 64 characters, such as
queue.length.valueFunc<CancellationToken, Task<double>>Reads the value.
unitstringWhat it counts, such as
percentoritems; the graph's axis label. Optional.
Returns
Exceptions
- ArgumentException
The name is empty, too long, taken or built in, or there are too many.
AddMetric(string, Func<Task<double>>, string)
Adds a value of the application's own to every heartbeat, such as a queue's length. Read on each heartbeat; a read that throws is logged and left out of that heartbeat, never stopping it.
public HeartbeatReportingOptions AddMetric(string name, Func<Task<double>> value, string unit = null)
Parameters
namestringUnique, at most 64 characters, such as
queue.length.valueFunc<Task<double>>Reads the value.
unitstringWhat it counts, such as
percentoritems; the graph's axis label. Optional.
Returns
Exceptions
- ArgumentException
The name is empty, too long, taken or built in, or there are too many.
AddMetricProvider<T>()
Adds a service that supplies metrics to every heartbeat, resolved from dependency injection so it can take any other service in its constructor. See IHeartbeatMetricProvider.
public HeartbeatReportingOptions AddMetricProvider<T>() where T : class, IHeartbeatMetricProvider
Returns
Type Parameters
TThe provider. Registered scoped; one is resolved per heartbeat.