3 types derived from Instrument
System.Diagnostics.DiagnosticSource (3)
System\Diagnostics\Metrics\Instrument.common.cs (1)
16
public abstract partial class Instrument<T> :
Instrument
where T : struct
System\Diagnostics\Metrics\Instrument.netcore.cs (1)
16
public abstract partial class Instrument<T> :
Instrument
where T : struct
System\Diagnostics\Metrics\ObservableInstrument.cs (1)
15
public abstract class ObservableInstrument<T> :
Instrument
where T : struct
121 references to Instrument
Interop.FunctionalTests (1)
Http2\Http2RequestTests.cs (1)
53
meterListener.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)
29
public bool InstrumentPublished(
Instrument
instrument, out object? userState)
42
public void MeasurementsCompleted(
Instrument
instrument, object? userState)
61
private void MeasurementHandler<T>(
Instrument
instrument, T measurement, ReadOnlySpan<KeyValuePair<string, object?>> tags, object? state) where T : struct
Metrics\ListenerSubscription.cs (6)
16
private readonly Dictionary<
Instrument
, object?> _instruments = new();
44
private void InstrumentPublished(
Instrument
instrument, MeterListener _)
65
private void MeasurementsCompleted(
Instrument
instrument, object? state)
102
private void RefreshInstrument(
Instrument
instrument)
129
private InstrumentRule? GetMostSpecificRule(
Instrument
instrument)
145
internal 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>
31
public 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>
38
public 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)
220
listener.InstrumentPublished = (
Instrument
instrument, MeterListener meterListener)
303
listener.InstrumentPublished = (
Instrument
instrument, MeterListener meterListener)
362
private static void OnInstrumentPublished(
Instrument
instrument, MeterListener meterListener, object? meterScope)
382
Instrument
instrument, double value,
Linux\LinuxCountersTests.cs (1)
100
var samples = new List<(
Instrument
instrument, long value)>();
Linux\LinuxUtilizationProviderTests.cs (2)
65
var samples = new List<(
Instrument
instrument, double value)>();
134
var samples = new List<(
Instrument
instrument, double value)>();
Windows\WindowsCountersTests.cs (2)
50
var samples = new List<(
Instrument
instrument, long value)>();
92
var samples = new List<(
Instrument
instrument, long value)>();
Microsoft.Extensions.Diagnostics.Testing (4)
Metrics\MetricCollector.cs (4)
41
private
Instrument
? _instrument;
153
public
Instrument
? Instrument => _instrument;
272
private void Initialize(Func<
Instrument
, bool> instrumentPredicate)
296
private void OnMeasurementRecorded(
Instrument
instrument, T measurement, ReadOnlySpan<KeyValuePair<string, object?>> tags, object? state)
Microsoft.Extensions.Resilience.PerformanceTests (1)
MetricsUtil.cs (1)
29
Instrument
instrument,
System.Diagnostics.DiagnosticSource (78)
System\Diagnostics\Metrics\AggregationManager.cs (20)
23
private readonly List<Predicate<
Instrument
>> _instrumentConfigFuncs = new();
28
private Dictionary<
Instrument
, bool> _instruments = new();
29
private readonly ConcurrentDictionary<
Instrument
, InstrumentState> _instrumentStates = new();
35
private readonly Action<
Instrument
, LabeledAggregationStatistics, InstrumentState?> _collectMeasurement;
38
private readonly Action<
Instrument
, InstrumentState> _beginInstrumentMeasurements;
39
private readonly Action<
Instrument
, InstrumentState> _endInstrumentMeasurements;
40
private readonly Action<
Instrument
, InstrumentState?> _instrumentPublished;
50
Action<
Instrument
, LabeledAggregationStatistics, InstrumentState?> collectMeasurement,
53
Action<
Instrument
, InstrumentState> beginInstrumentMeasurements,
54
Action<
Instrument
, InstrumentState> endInstrumentMeasurements,
55
Action<
Instrument
, InstrumentState?> instrumentPublished,
110
private void Include(Predicate<
Instrument
> instrumentFilter)
129
private void CompletedMeasurements(
Instrument
instrument, object? cookie)
137
private void PublishedInstrument(
Instrument
instrument, MeterListener _)
260
private void RemoveInstrumentState(
Instrument
instrument)
265
private InstrumentState? GetInstrumentState(
Instrument
instrument)
271
foreach (Predicate<
Instrument
> filter in _instrumentConfigFuncs)
294
internal InstrumentState? BuildInstrumentState(
Instrument
instrument)
306
private Func<Aggregator?>? GetAggregatorFactory(
Instrument
instrument)
439
foreach (KeyValuePair<
Instrument
, InstrumentState> kv in _instrumentStates)
System\Diagnostics\Metrics\Instrument.common.cs (1)
87
protected 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
"/>.
93
lock (
Instrument
.SyncObject)
System\Diagnostics\Metrics\InstrumentAdvice.cs (1)
22
Instrument
.ValidateTypeParameter<T>();
System\Diagnostics\Metrics\InstrumentState.cs (2)
17
public abstract void Collect(
Instrument
instrument, Action<LabeledAggregationStatistics> aggregationVisitFunc);
34
public 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;
106
return
Instrument
.EmptyTags;
116
return
Instrument
.EmptyTags;
142
return
Instrument
.EmptyTags;
System\Diagnostics\Metrics\Meter.cs (23)
19
private List<
Instrument
> _instruments = new List<
Instrument
>();
20
private Dictionary<string, List<
Instrument
>> _nonObservableInstrumentsCache = new();
95
lock (
Instrument
.SyncObject)
495
List<
Instrument
>? instruments = null;
497
lock (
Instrument
.SyncObject)
507
_instruments = new List<
Instrument
>();
517
foreach (
Instrument
instrument in instruments)
524
private static
Instrument
? GetCachedInstrument(List<
Instrument
> instrumentList, Type instrumentType, string? unit, string? description, IEnumerable<KeyValuePair<string, object?>>? tags)
527
foreach (
Instrument
instrument in instrumentList)
540
private
Instrument
GetOrCreateInstrument<T>(Type instrumentType, string name, string? unit, string? description, IEnumerable<KeyValuePair<string, object?>>? tags, Func<
Instrument
> instrumentCreator)
542
List<
Instrument
>? instrumentList;
548
instrumentList = new List<
Instrument
>();
558
Instrument
? cachedInstrument = GetCachedInstrument(instrumentList, instrumentType, unit, description, tags);
565
Instrument
newInstrument = instrumentCreator.Invoke();
571
Instrument
? cachedInstrument = GetCachedInstrument(instrumentList, instrumentType, unit, description, tags);
585
internal bool AddInstrument(
Instrument
instrument)
597
internal static List<
Instrument
>? GetPublishedInstruments()
599
List<
Instrument
>? instruments = null;
603
instruments = new List<
Instrument
>();
607
foreach (
Instrument
instrument in meter._instruments)
System\Diagnostics\Metrics\MeterListener.cs (20)
12
public delegate void MeasurementCallback<T>(
Instrument
instrument, T measurement, ReadOnlySpan<KeyValuePair<string, object?>> tags, object? state) where T : struct;
24
private readonly DiagLinkedList<
Instrument
> _enabledMeasurementInstruments = new DiagLinkedList<
Instrument
>();
50
public Action<
Instrument
, MeterListener>? InstrumentPublished { get; set; }
56
public Action<
Instrument
, object?>? MeasurementsCompleted { get; set; }
63
public void EnableMeasurementEvents(
Instrument
instrument, object? state = null)
74
lock (
Instrument
.SyncObject)
104
public object? DisableMeasurementEvents(
Instrument
instrument)
112
lock (
Instrument
.SyncObject)
184
List<
Instrument
>? publishedInstruments = null;
185
lock (
Instrument
.SyncObject)
201
foreach (
Instrument
instrument in publishedInstruments)
219
DiagNode<
Instrument
>? current = _enabledMeasurementInstruments.First;
254
Dictionary<
Instrument
, object?>? callbacksArguments = null;
255
Action<
Instrument
, object?>? measurementsCompleted = MeasurementsCompleted;
257
lock (
Instrument
.SyncObject)
266
DiagNode<
Instrument
>? current = _enabledMeasurementInstruments.First;
271
callbacksArguments = new Dictionary<
Instrument
, object?>();
287
foreach (KeyValuePair<
Instrument
, object?> kvp in callbacksArguments)
298
internal void NotifyMeasurement<T>(
Instrument
instrument, T measurement, ReadOnlySpan<KeyValuePair<string, object?>> tags, object? state) where T : struct
System\Diagnostics\Metrics\MetricsEventSource.cs (1)
698
private static void TransmitMetricValue(
Instrument
instrument, LabeledAggregationStatistics stats, string sessionId, InstrumentState? instrumentState)