Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Diagnostics.​Metrics.​MeterListener
Assembly: System.Diagnostics.DiagnosticSource
Inheritance: object → MeterListener
Implemented Interfaces
The MeterListener is class used to listen to the metrics instrument measurements recording.
Properties
InstrumentPublished
Gets or sets the callback to get notified when an instrument is published.
public
Action<​Instrument, object>
MeasurementsCompleted
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 <see cref="M:System.Diagnostics.Metrics.MeterListener.Dispose" /> on the listener.
Methods
public
object
DisableMeasurementEvents​(Instrument instrument)
Stops listening to a specific instrument measurement recording.
Returns The state object originally passed to <see cref="M:System.Diagnostics.Metrics.MeterListener.EnableMeasurementEvents(System.Diagnostics.Metrics.Instrument,System.Object)" /> method.
instrument
The instrument to stop listening to.
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.
instrument
The instrument to listen to.
state
A state object that will be passed back to the callback getting measurements events.
public
void
RecordObservableInstruments​()
Calls all Observable instruments that the listener is listening to, and calls <see cref="M:System.Diagnostics.Metrics.MeterListener.SetMeasurementEventCallback``1(System.Diagnostics.Metrics.MeasurementCallback{``0})" /> with every collected measurement.
public
void
SetMeasurementEventCallback​(MeasurementCallback?<​T> measurementCallback)
Sets a callback for a specific numeric type to get the measurement recording notification from all instruments that enabled listening and were 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.
measurementCallback
The callback that can be used to get measurement recording of numeric type T.
public
void
Start​()
Enables the listener to start listening to instruments measurement recording.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object