| File: System\Diagnostics\Metrics\Instrument.netcore.cs | Web Access |
| Project: src\runtime\src\libraries\System.Diagnostics.DiagnosticSource\src\System.Diagnostics.DiagnosticSource.csproj (System.Diagnostics.DiagnosticSource) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System.Diagnostics.Metrics { /// <summary> /// Instrument{T} is the base class from which all non-observable instruments will inherit from. /// </summary> /// <remarks> /// This class supports only the following generic parameter types: <see cref="byte" />, <see cref="short" />, <see cref="int" />, <see cref="long" />, <see cref="float" />, <see cref="double" />, and <see cref="decimal" /> /// </remarks> public abstract partial class Instrument<T> : Instrument where T : struct { /// <summary> /// Record the measurement by notifying all <see cref="MeterListener" /> objects which listening to this instrument. /// </summary> /// <param name="measurement">The measurement value.</param> /// <param name="tag">A key-value pair tag associated with the measurement.</param> protected void RecordMeasurement(T measurement, KeyValuePair<string, object?> tag) => RecordMeasurement(measurement, [tag]); /// <summary> /// Record the measurement by notifying all <see cref="MeterListener" /> objects which listening to this instrument. /// </summary> /// <param name="measurement">The measurement value.</param> /// <param name="tag1">A first key-value pair tag associated with the measurement.</param> /// <param name="tag2">A second key-value pair tag associated with the measurement.</param> protected void RecordMeasurement(T measurement, KeyValuePair<string, object?> tag1, KeyValuePair<string, object?> tag2) => RecordMeasurement(measurement, [tag1, tag2]); /// <summary> /// Record the measurement by notifying all <see cref="MeterListener" /> objects which listening to this instrument. /// </summary> /// <param name="measurement">The measurement value.</param> /// <param name="tag1">A first key-value pair tag associated with the measurement.</param> /// <param name="tag2">A second key-value pair tag associated with the measurement.</param> /// <param name="tag3">A third key-value pair tag associated with the measurement.</param> protected void RecordMeasurement(T measurement, KeyValuePair<string, object?> tag1, KeyValuePair<string, object?> tag2, KeyValuePair<string, object?> tag3) => RecordMeasurement(measurement, [tag1, tag2, tag3]); /// <summary> /// Record the measurement by notifying all <see cref="MeterListener" /> objects which listening to this instrument. /// </summary> /// <param name="measurement">The measurement value.</param> /// <param name="tagList">A <see cref="T:System.Diagnostics.TagList" /> of tags associated with the measurement.</param> protected void RecordMeasurement(T measurement, in TagList tagList) => RecordMeasurement(measurement, tagList.Tags); } }