Summary
In this chapter, we explored metrics in .NET and OpenTelemetry.
Metrics allow us to collect aggregated multi-dimensional data. They produce unbiased telemetry with a predictable volume at any scale and allow us to monitor system health, performance, and usage.
Metrics can’t have high-cardinality attributes, so we can’t use them to detect problems that happen in specific and narrow cases – for this, we need distributed tracing or events. .NET provides an OpenTelemetry metrics implementation that consists of the Meter
class, which can create specific instruments: counters, gauges, and histograms.
Counters are used to report additive values and can be synchronous or asynchronous. Gauges report current, non-additive values asynchronously, while histograms report value distribution.
With this, you should be able to identify scenarios where metrics are beneficial, choose appropriate instruments, and efficiently report metrics in your application....