METHOD

Meter.CreateObservableGauge<T>

Registers a callback reporting a current non-additive measurement when observed. Keep the callback bounded and safe for the collection context. A gauge is not a cumulative event count.

Formal Syntax & Structure

csharp syntaxcsharp
meter.CreateObservableGauge<int>("queue.depth", () => depth)

Working Example

Example Snippetcsharp
using System;using System.Linq;using System.Diagnostics;using System.Diagnostics.Metrics;using var meter = new Meter("ByteMind.Demo"); int depth=3; var gauge=meter.CreateObservableGauge<int>("queue.depth",()=>depth); Console.WriteLine(gauge.Name); // queue.depth
C# & .NET Reference