<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.0-preview.2.23128.3" />

MeterListener

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

Callbacks to get notification when an instrument is published.

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

Callbacks to get notification when stopping the measurement on some instrument. This can happen when the Meter or the Listener is disposed or calling Dispose on the listener.

public MeterListener()

Creates a MeterListener object.

public object DisableMeasurementEvents(Instrument instrument)

Stop 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)

Start listening to a specific instrument measurement recording.

Calls all Observable instruments which the listener is listening to then 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()

Enable the listener to start listening to instruments measurement recording.