System.Diagnostics.Metrics in .NET provides seven instrument types for recording metrics: Counter, ObservableCounter, UpDownCounter, ObservableUpDownCounter, Gauge, ObservableGauge, and Histogram. Observable instruments are polled by consumers on-demand, while standard instruments emit values as events occur. Each type serves specific use cases—counters track occurrences, up-down counters handle bidirectional changes, gauges record point-in-time values, and histograms capture distributions for statistical analysis. Examples from .NET runtime and ASP.NET Core demonstrate real-world implementations like tracking GC heap size, active HTTP requests, and request durations.
Table of contents
System.Diagnostics.Metrics APIsWhat is an Observable* instrument?Understanding the different Instrument typesSummarySort: