Gauge<T>
The Gauge is an instrument used to record non-additive values whenever changes occur. For example, record the room background noise level value when changes occur.
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.Diagnostics.Metrics
{
public sealed class Gauge<T> : Instrument<T> where T : struct
{
internal Gauge(Meter meter, string name, string unit, string description)
: this(meter, name, unit, description, (IEnumerable<KeyValuePair<string, object>>)null)
{
}
internal Gauge(Meter meter, string name, string unit, string description, IEnumerable<KeyValuePair<string, object>> tags)
: base(meter, name, unit, description, tags)
{
Publish();
}
public void Record(T value)
{
RecordMeasurement(value);
}
public void Record(T value, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
2
})] KeyValuePair<string, object> tag)
{
RecordMeasurement(value, tag);
}
public void Record(T value, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
2
})] KeyValuePair<string, object> tag1, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
2
})] KeyValuePair<string, object> tag2)
{
RecordMeasurement(value, tag1, tag2);
}
public void Record(T value, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
2
})] KeyValuePair<string, object> tag1, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
2
})] KeyValuePair<string, object> tag2, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
2
})] KeyValuePair<string, object> tag3)
{
RecordMeasurement(value, tag1, tag2, tag3);
}
public void Record(T value, [System.Runtime.CompilerServices.ParamCollection] [System.Runtime.CompilerServices.ScopedRef] [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
0,
1,
2
})] ReadOnlySpan<KeyValuePair<string, object>> tags)
{
RecordMeasurement(value, tags);
}
public void Record(T value, [System.Runtime.CompilerServices.Nullable(new byte[] {
1,
0,
1,
2
})] params KeyValuePair<string, object>[] tags)
{
RecordMeasurement(value, MemoryExtensions.AsSpan<KeyValuePair<string, object>>(tags));
}
public void Record(T value, [In] [System.Runtime.CompilerServices.IsReadOnly] ref TagList tagList)
{
RecordMeasurement(value, ref tagList);
}
}
}