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
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public class PollingCounter : System.Diagnostics.Tracing.DiagnosticCounter
type PollingCounter = class
    inherit DiagnosticCounter
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
type PollingCounter = class
    inherit DiagnosticCounter
Public Class PollingCounter
Inherits DiagnosticCounter
Inheritance
PollingCounter
Attributes

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

Initializes a new instance of the PollingCounter class.

Properties

DisplayName

Gets or sets the display name of the counter.

(Inherited from DiagnosticCounter)
DisplayUnits

Gets or sets the display units of the counter.

(Inherited from DiagnosticCounter)
EventSource

Gets the EventSource that this counter is attached to.

(Inherited from DiagnosticCounter)
Name

Gets the name of this counter.

(Inherited from DiagnosticCounter)

Methods

AddMetadata(String, String)

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

(Inherited from DiagnosticCounter)
Dispose()

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

(Inherited from DiagnosticCounter)
Equals(Object)

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

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string representation of the current polling counter instance.

Applies to

See also