Skip to content
etishor edited this page Oct 18, 2014 · 7 revisions

A gauge is the simplest metric type. It represents an instantaneous value.

The basic gauge is created from a function that returns a double value. There is also the possibility to create a Gauge based on a performance counter. For advanced scenarios, the library also provides a DerivedGauge, which represents a Gauge that derives its value from another Gauge:

Gauges are registered by calling the appropriate methods on the static Metric class or on a child MetricsContext. See metrics grouping & organization for details.

// gauge from Func<double>
Metric.Gauge("MyValue", () => ComputeMagicValue(), Unit.Items);
    
// gauge that reads its value from a performance counter
Metric.PerformanceCounter("CPU Usage", "Processor", "% Processor Time",
    "_Total", Unit.Custom("%"));

// gauge that transforms the value of another gauge    
Metric.Advanced.Gauge("Kbytes gauge", 
    () => new DerivedGauge(gaugeReturningValueInBytes, v => v / 1024.0 ),
    Unit.KiloBytes);