3 types derived from Instrument
System.Diagnostics.DiagnosticSource (3)
System\Diagnostics\Metrics\Instrument.common.cs (1)
16public abstract partial class Instrument<T> : Instrument where T : struct
System\Diagnostics\Metrics\Instrument.netcore.cs (1)
16public abstract partial class Instrument<T> : Instrument where T : struct
System\Diagnostics\Metrics\ObservableInstrument.cs (1)
15public abstract class ObservableInstrument<T> : Instrument where T : struct
121 references to Instrument
Interop.FunctionalTests (1)
Http2\Http2RequestTests.cs (1)
53meterListener.SetMeasurementEventCallback<double>((Instrument instrument, double measurement, ReadOnlySpan<KeyValuePair<string, object>> tags, object state) =>
Microsoft.Extensions.Diagnostics (10)
Metrics\Configuration\MetricsBuilderConfigurationExtensions.cs (1)
20/// which <see cref="Meter">Meters</see>, <see cref="Instrument">Instruments</see>, and <see cref="IMetricsListener">IMetricsListeners</see> are enabled.
Metrics\DebugConsoleMetricListener.cs (3)
29public bool InstrumentPublished(Instrument instrument, out object? userState) 42public void MeasurementsCompleted(Instrument instrument, object? userState) 61private void MeasurementHandler<T>(Instrument instrument, T measurement, ReadOnlySpan<KeyValuePair<string, object?>> tags, object? state) where T : struct
Metrics\ListenerSubscription.cs (6)
16private readonly Dictionary<Instrument, object?> _instruments = new(); 44private void InstrumentPublished(Instrument instrument, MeterListener _) 65private void MeasurementsCompleted(Instrument instrument, object? state) 102private void RefreshInstrument(Instrument instrument) 129private InstrumentRule? GetMostSpecificRule(Instrument instrument) 145internal static bool RuleMatches(InstrumentRule rule, Instrument instrument, string listenerName, IMeterFactory meterFactory)
Microsoft.Extensions.Diagnostics.Abstractions (17)
Metrics\IMetricsListener.cs (6)
27/// <param name="instrument">The new <see cref="Instrument"/>.</param> 29/// and <see cref="MeasurementsCompleted(Instrument, object?)"/>.</param> 31public bool InstrumentPublished(Instrument instrument, out object? userState); 36/// <param name="instrument">The <see cref="Instrument"/> being disabled.</param> 37/// <param name="userState">The original listener state returned by <see cref="InstrumentPublished(Instrument, out object?)"/>.</param> 38public void MeasurementsCompleted(Instrument instrument, object? userState);
Metrics\InstrumentRule.cs (3)
16/// <para>- InstrumentName, an exact match. <see cref="Instrument.Name">Instrument.Name</see>.</para> 21/// <param name="instrumentName">The <see cref="Instrument.Name">Instrument.Name</see>.</param> 36/// Gets the <see cref="Instrument.Name">Instrument.Name</see>, an exact match.
Metrics\MetricsBuilderExtensions.Rules.cs (8)
25/// Enables a specified <see cref="Instrument"/> for the given <see cref="Meter"/> and <see cref="IMetricsListener"/>. 29/// <param name="instrumentName">The <see cref="Instrument.Name"/>. A null value matches all instruments.</param> 47/// Enables a specified <see cref="Instrument"/> for the given <see cref="Meter"/> and <see cref="IMetricsListener"/>. 51/// <param name="instrumentName">The <see cref="Instrument.Name"/>. A null value matches all instruments.</param> 69/// Disables a specified <see cref="Instrument"/> for the given <see cref="Meter"/> and <see cref="IMetricsListener"/>. 73/// <param name="instrumentName">The <see cref="Instrument.Name"/>. A null value matches all instruments.</param> 91/// Disables a specified <see cref="Instrument"/> for the given <see cref="Meter"/> and <see cref="IMetricsListener"/>. 95/// <param name="instrumentName">The <see cref="Instrument.Name"/>. A null value matches all instruments.</param>
Microsoft.Extensions.Diagnostics.ResourceMonitoring (1)
ResourceUtilizationInstruments.cs (1)
11/// <seealso cref="System.Diagnostics.Metrics.Instrument"/>
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests (9)
Linux\AcceptanceTest.cs (4)
220listener.InstrumentPublished = (Instrument instrument, MeterListener meterListener) 303listener.InstrumentPublished = (Instrument instrument, MeterListener meterListener) 362private static void OnInstrumentPublished(Instrument instrument, MeterListener meterListener, object? meterScope) 382Instrument instrument, double value,
Linux\LinuxCountersTests.cs (1)
100var samples = new List<(Instrument instrument, long value)>();
Linux\LinuxUtilizationProviderTests.cs (2)
65var samples = new List<(Instrument instrument, double value)>(); 134var samples = new List<(Instrument instrument, double value)>();
Windows\WindowsCountersTests.cs (2)
50var samples = new List<(Instrument instrument, long value)>(); 92var samples = new List<(Instrument instrument, long value)>();
Microsoft.Extensions.Diagnostics.Testing (4)
Metrics\MetricCollector.cs (4)
41private Instrument? _instrument; 153public Instrument? Instrument => _instrument; 272private void Initialize(Func<Instrument, bool> instrumentPredicate) 296private void OnMeasurementRecorded(Instrument instrument, T measurement, ReadOnlySpan<KeyValuePair<string, object?>> tags, object? state)
Microsoft.Extensions.Resilience.PerformanceTests (1)
MetricsUtil.cs (1)
29Instrument instrument,
System.Diagnostics.DiagnosticSource (78)
System\Diagnostics\Metrics\AggregationManager.cs (20)
23private readonly List<Predicate<Instrument>> _instrumentConfigFuncs = new(); 28private Dictionary<Instrument, bool> _instruments = new(); 29private readonly ConcurrentDictionary<Instrument, InstrumentState> _instrumentStates = new(); 35private readonly Action<Instrument, LabeledAggregationStatistics, InstrumentState?> _collectMeasurement; 38private readonly Action<Instrument, InstrumentState> _beginInstrumentMeasurements; 39private readonly Action<Instrument, InstrumentState> _endInstrumentMeasurements; 40private readonly Action<Instrument, InstrumentState?> _instrumentPublished; 50Action<Instrument, LabeledAggregationStatistics, InstrumentState?> collectMeasurement, 53Action<Instrument, InstrumentState> beginInstrumentMeasurements, 54Action<Instrument, InstrumentState> endInstrumentMeasurements, 55Action<Instrument, InstrumentState?> instrumentPublished, 110private void Include(Predicate<Instrument> instrumentFilter) 129private void CompletedMeasurements(Instrument instrument, object? cookie) 137private void PublishedInstrument(Instrument instrument, MeterListener _) 260private void RemoveInstrumentState(Instrument instrument) 265private InstrumentState? GetInstrumentState(Instrument instrument) 271foreach (Predicate<Instrument> filter in _instrumentConfigFuncs) 294internal InstrumentState? BuildInstrumentState(Instrument instrument) 306private Func<Aggregator?>? GetAggregatorFactory(Instrument instrument) 439foreach (KeyValuePair<Instrument, InstrumentState> kv in _instrumentStates)
System\Diagnostics\Metrics\Instrument.common.cs (1)
87protected void RecordMeasurement(T measurement) => RecordMeasurement(measurement, Instrument.EmptyTags.AsSpan());
System\Diagnostics\Metrics\Instrument.cs (4)
32/// Constructs a new instance of <see cref="Instrument"/>. 42/// Constructs a new instance of <see cref="Instrument"/>. 55/// Constructs a new instance of <see cref="Instrument"/>. 93lock (Instrument.SyncObject)
System\Diagnostics\Metrics\InstrumentAdvice.cs (1)
22Instrument.ValidateTypeParameter<T>();
System\Diagnostics\Metrics\InstrumentState.cs (2)
17public abstract void Collect(Instrument instrument, Action<LabeledAggregationStatistics> aggregationVisitFunc); 34public override void Collect(Instrument instrument, Action<LabeledAggregationStatistics> aggregationVisitFunc)
System\Diagnostics\Metrics\Measurement.cs (6)
24_tags = Instrument.EmptyTags; 53_tags = Instrument.EmptyTags; 86_tags = Instrument.EmptyTags; 106return Instrument.EmptyTags; 116return Instrument.EmptyTags; 142return Instrument.EmptyTags;
System\Diagnostics\Metrics\Meter.cs (23)
19private List<Instrument> _instruments = new List<Instrument>(); 20private Dictionary<string, List<Instrument>> _nonObservableInstrumentsCache = new(); 95lock (Instrument.SyncObject) 495List<Instrument>? instruments = null; 497lock (Instrument.SyncObject) 507_instruments = new List<Instrument>(); 517foreach (Instrument instrument in instruments) 524private static Instrument? GetCachedInstrument(List<Instrument> instrumentList, Type instrumentType, string? unit, string? description, IEnumerable<KeyValuePair<string, object?>>? tags) 527foreach (Instrument instrument in instrumentList) 540private Instrument GetOrCreateInstrument<T>(Type instrumentType, string name, string? unit, string? description, IEnumerable<KeyValuePair<string, object?>>? tags, Func<Instrument> instrumentCreator) 542List<Instrument>? instrumentList; 548instrumentList = new List<Instrument>(); 558Instrument? cachedInstrument = GetCachedInstrument(instrumentList, instrumentType, unit, description, tags); 565Instrument newInstrument = instrumentCreator.Invoke(); 571Instrument? cachedInstrument = GetCachedInstrument(instrumentList, instrumentType, unit, description, tags); 585internal bool AddInstrument(Instrument instrument) 597internal static List<Instrument>? GetPublishedInstruments() 599List<Instrument>? instruments = null; 603instruments = new List<Instrument>(); 607foreach (Instrument instrument in meter._instruments)
System\Diagnostics\Metrics\MeterListener.cs (20)
12public delegate void MeasurementCallback<T>(Instrument instrument, T measurement, ReadOnlySpan<KeyValuePair<string, object?>> tags, object? state) where T : struct; 24private readonly DiagLinkedList<Instrument> _enabledMeasurementInstruments = new DiagLinkedList<Instrument>(); 50public Action<Instrument, MeterListener>? InstrumentPublished { get; set; } 56public Action<Instrument, object?>? MeasurementsCompleted { get; set; } 63public void EnableMeasurementEvents(Instrument instrument, object? state = null) 74lock (Instrument.SyncObject) 104public object? DisableMeasurementEvents(Instrument instrument) 112lock (Instrument.SyncObject) 184List<Instrument>? publishedInstruments = null; 185lock (Instrument.SyncObject) 201foreach (Instrument instrument in publishedInstruments) 219DiagNode<Instrument>? current = _enabledMeasurementInstruments.First; 254Dictionary<Instrument, object?>? callbacksArguments = null; 255Action<Instrument, object?>? measurementsCompleted = MeasurementsCompleted; 257lock (Instrument.SyncObject) 266DiagNode<Instrument>? current = _enabledMeasurementInstruments.First; 271callbacksArguments = new Dictionary<Instrument, object?>(); 287foreach (KeyValuePair<Instrument, object?> kvp in callbacksArguments) 298internal void NotifyMeasurement<T>(Instrument instrument, T measurement, ReadOnlySpan<KeyValuePair<string, object?>> tags, object? state) where T : struct
System\Diagnostics\Metrics\MetricsEventSource.cs (1)
698private static void TransmitMetricValue(Instrument instrument, LabeledAggregationStatistics stats, string sessionId, InstrumentState? instrumentState)