3 types derived from Instrument
System.Diagnostics.DiagnosticSource (3)
115 references to Instrument
Microsoft.Extensions.Diagnostics (10)
Microsoft.Extensions.Diagnostics.Abstractions (17)
Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization (3)
Microsoft.Extensions.Diagnostics.ResourceMonitoring (1)
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests (2)
Microsoft.Extensions.Diagnostics.Testing (4)
Microsoft.Extensions.Resilience.PerformanceTests (1)
System.Diagnostics.DiagnosticSource (77)
System\Diagnostics\Metrics\AggregationManager.cs (20)
22private readonly List<Predicate<Instrument>> _instrumentConfigFuncs = new();
27private Dictionary<Instrument, bool> _instruments = new();
28private readonly ConcurrentDictionary<Instrument, InstrumentState> _instrumentStates = new();
37private readonly Action<Instrument, LabeledAggregationStatistics, InstrumentState?> _collectMeasurement;
40private readonly Action<Instrument, InstrumentState> _beginInstrumentMeasurements;
41private readonly Action<Instrument, InstrumentState> _endInstrumentMeasurements;
42private readonly Action<Instrument, InstrumentState?> _instrumentPublished;
56Action<Instrument, LabeledAggregationStatistics, InstrumentState?> collectMeasurement,
59Action<Instrument, InstrumentState> beginInstrumentMeasurements,
60Action<Instrument, InstrumentState> endInstrumentMeasurements,
61Action<Instrument, InstrumentState?> instrumentPublished,
116private void Include(Predicate<Instrument> instrumentFilter)
145private void CompletedMeasurements(Instrument instrument, object? cookie)
153private void PublishedInstrument(Instrument instrument, MeterListener _)
333private void RemoveInstrumentState(Instrument instrument)
338private InstrumentState? GetInstrumentState(Instrument instrument)
344foreach (Predicate<Instrument> filter in _instrumentConfigFuncs)
367internal InstrumentState? BuildInstrumentState(Instrument instrument)
379private Func<Aggregator?>? GetAggregatorFactory(Instrument instrument)
510foreach (KeyValuePair<Instrument, InstrumentState> kv in _instrumentStates)
System\Diagnostics\Metrics\Meter.cs (23)
19private List<Instrument> _instruments = new List<Instrument>();
20private Dictionary<string, List<Instrument>> _nonObservableInstrumentsCache = new();
90lock (Instrument.SyncObject)
496List<Instrument>? instruments = null;
498lock (Instrument.SyncObject)
508_instruments = new List<Instrument>();
518foreach (Instrument instrument in instruments)
525private static Instrument? GetCachedInstrument(List<Instrument> instrumentList, Type instrumentType, string? unit, string? description, IEnumerable<KeyValuePair<string, object?>>? tags)
528foreach (Instrument instrument in instrumentList)
541private Instrument GetOrCreateInstrument<T>(Type instrumentType, string name, string? unit, string? description, IEnumerable<KeyValuePair<string, object?>>? tags, Func<Instrument> instrumentCreator)
543List<Instrument>? instrumentList;
549instrumentList = new List<Instrument>();
559Instrument? cachedInstrument = GetCachedInstrument(instrumentList, instrumentType, unit, description, tags);
566Instrument newInstrument = instrumentCreator.Invoke();
572Instrument? cachedInstrument = GetCachedInstrument(instrumentList, instrumentType, unit, description, tags);
586internal bool AddInstrument(Instrument instrument)
598internal static List<Instrument>? GetPublishedInstruments()
600List<Instrument>? instruments = null;
604instruments = new List<Instrument>();
608foreach (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