PollingCounter PollingCounter PollingCounter PollingCounter Class

Definition

Provides a variant of EventCounter that collects and calculates similar statistics as EventCounter.

public ref class PollingCounter : System::Diagnostics::Tracing::DiagnosticCounter
public class PollingCounter : System.Diagnostics.Tracing.DiagnosticCounter
type PollingCounter = class
    inherit DiagnosticCounter
Public Class PollingCounter
Inherits DiagnosticCounter
Inheritance

Remarks

PollingCounter is a variant of EventCounter that uses a callback method to poll for values rather than requiring the writer to explicitly call EventCounter.WriteMetric each time a value is tracked, metricProvider is a callback method that polls for values. The PollingCounter instance polls and reports a value retrieved by calling metricProvider exactly once per the interval requested by the listener.

A PollingCounter lives as long as the EventSource that it is attached to unless it is explicitly disposed.

PollingCounter differs from EventCounter in that it takes a callback function to collect metrics on its own rather than requiring the user to call WriteMetric every time.

For an example that uses PollingCounter inside the runtime for runtime performance counters, see the CoreCLR source for RuntimeEventSource on GitHub.

Constructors

PollingCounter(String, EventSource, Func<Double>) PollingCounter(String, EventSource, Func<Double>) PollingCounter(String, EventSource, Func<Double>) PollingCounter(String, EventSource, Func<Double>)

Initializes a new instance of the PollingCounter class.

Methods

AddMetadata(String, String) AddMetadata(String, String) AddMetadata(String, String) AddMetadata(String, String)

Adds key-value metadata to the counter that will be included as a part of the payload

(Inherited from DiagnosticCounter)
Dispose() Dispose() Dispose() Dispose()

Removes the counter from the set that the EventSource will report on.

(Inherited from DiagnosticCounter)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string representation of the current polling counter instance.

Properties

DisplayName DisplayName DisplayName DisplayName

Gets or sets the display name of the counter.

(Inherited from DiagnosticCounter)
DisplayUnits DisplayUnits DisplayUnits DisplayUnits

Gets or sets the display units of the counter.

(Inherited from DiagnosticCounter)
EventSource EventSource EventSource EventSource

Gets the EventSource that this counter is attached to.

(Inherited from DiagnosticCounter)
Name Name Name Name

Gets the name of this counter.

(Inherited from DiagnosticCounter)

Applies to