Uredi

Deli z drugimi prek


System.Diagnostics.Metrics Namespace

Metrics are numerical measurements reported over time, most often used to monitor the health of an application and generate alerts. For example, a web service might track how many requests it receives each second, how many milliseconds it took to respond, and how many of the responses sent an error back to the user. These metrics can be reported to a monitoring system at frequent, regular intervals. The System.Diagnostics.Metrics namespace can be used to add metrics to an application. The APIs work on all platforms supported by .NET and are designed to integrate well with OpenTelemetry's growing ecosystem of tools. They also integrate with .NET SDK tools, such as dotnet-counters. A listener API is available for developers that want to create custom tooling or adapters to other systems.

Classes

Counter<T>

Represents an instrument that supports adding non-negative values. For example, you might call counter.Add(1) each time a request is processed to track the total number of requests. Most metric viewers display counters using a rate (requests/sec), by default, but can also display a cumulative total.

Gauge<T>

The Gauge is an instrument used to record non-additive values whenever changes occur. For example, record the room background noise level value when changes occur.

Histogram<T>

Represents a metrics instrument that can be used to report arbitrary values that are likely to be statistically meaningful, for example, the request duration. Call CreateHistogram<T>(String, String, String) to create a Histogram object.

Instrument

Base class of all metrics instrument classes

Instrument<T>

The base class for all non-observable instruments.

InstrumentAdvice<T>

Contains configuration settings advised to be used by metrics consumers when recording measurements for a given Instrument<T>.

Meter

Meter is the class responsible for creating and tracking the Instruments.

MeterFactoryExtensions

Extension methods for Meter and IMeterFactory.

MeterListener

The MeterListener is class used to listen to the metrics instrument measurements recording.

MeterOptions

The options for creating a Meter.

ObservableCounter<T>

Represents a metrics-observable instrument that reports monotonically increasing values when the instrument is being observed, for example, CPU time (for different processes, threads, user mode, or kernel mode). Call CreateObservableCounter to create the observable counter object.

ObservableGauge<T>

Represents an observable instrument that reports non-additive values when the instrument is being observed, for example, the current room temperature. Call CreateObservableGauge to create the observable counter object.

ObservableInstrument<T>

ObservableInstrument{T} is the base class from which all metrics observable instruments will inherit.

ObservableUpDownCounter<T>

A metrics-observable instrument that reports increasing or decreasing values when the instrument is being observed. Use this instrument to monitor the process heap size or the approximate number of items in a lock-free circular buffer, for example. To create an ObservableUpDownCounter object, use the CreateObservableUpDownCounter methods.

UpDownCounter<T>

An instrument that supports reporting positive or negative metric values. UpDownCounter may be used in scenarios like reporting the change in active requests or queue size.

Structs

Measurement<T>

Stores one observed metrics value and its associated tags. This type is used by an Observable instrument's Observe() method when reporting current measurements.

Interfaces

IMeterFactory

A factory for creating Meter instances.

Delegates

MeasurementCallback<T>

A delegate to represent the Meterlistener callbacks that are used when recording measurements.