TaskHub.Shared

Counter Metric

A Counter is a cumulative metric that represents a single monotonically increasing value. It is used to count occurrences of events, such as the number of requests received or the number of errors encountered.

Factory

ICounterMetricFactory is an extension of IMetricServiceFactory that provides methods to create and manage Counter metrics services.

public interface ICounterMetricFactory : IMetricServiceFactory<ICounterMetric>;

Service

ICounterMetricService provides methods to interact with Counter metrics.

public interface ICounterMetricService : IMetricService
{
    void Inc();
    void Inc(params (string key, string value)[] labels);
    void Inc(double increment);
    void Inc(double increment, params (string key, string value)[] labels);
}

Usage

public class SomeClass(ICounterMetric metric)
{
	public void SomeMethod1()
	{
		metric.Inc();
	}
	public void SomeMethod2()
	{
		metric.Inc(("label1", "value1"), ("label2", "value2"));
	}
	public void SomeMethod3()
	{
		metric.Inc(10);
	}
	public void SomeMethod3()
	{
		metric.Inc(10, ("label1", "value1"), ("label2", "value2"));
	}
}