<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="9.0.0-preview.6.24327.7" />

MeterListener

public sealed class MeterListener : IDisposable
The MeterListener is class used to listen to the metrics instrument measurements recording.

Gets or sets the callback to get notified when an instrument is published.

public Action<Instrument, object> MeasurementsCompleted { get; set; }

Gets or sets the callback to get notified when the measurement is stopped on some instrument. This can happen when the Meter or the Listener is disposed or calling Dispose on the listener.

public MeterListener()

Initializes a new instance of the MeterListener class.

public object DisableMeasurementEvents(Instrument instrument)

Stops listening to a specific instrument measurement recording.

public void Dispose()

Disposes the listeners which will stop it from listening to any instrument.

public void EnableMeasurementEvents(Instrument instrument, object state = null)

Starts listening to a specific instrument measurement recording.

Calls all Observable instruments that the listener is listening to, and calls SetMeasurementEventCallback<T> with every collected measurement.

public void SetMeasurementEventCallback<T>(MeasurementCallback<T> measurementCallback) where T : struct

Sets a callback for a specific numeric type to get the measurement recording notification from all instruments which enabled listening and was created with the same specified numeric type. If a measurement of type T is recorded and a callback of type T is registered, that callback will be used.

public void Start()

Enables the listener to start listening to instruments measurement recording.