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
122 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)
src\Shared\Instruments\ResourceUtilizationInstruments.cs (1)
13
/// <seealso cref="System.Diagnostics.Metrics.
Instrument
"/>
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests (12)
Linux\AcceptanceTest.cs (6)
220
listener.InstrumentPublished = (
Instrument
instrument, MeterListener meterListener)
303
listener.InstrumentPublished = (
Instrument
instrument, MeterListener meterListener)
391
listener.InstrumentPublished = (
Instrument
instrument, MeterListener meterListener)
467
listener.InstrumentPublished = (
Instrument
instrument, MeterListener meterListener)
518
private static void OnInstrumentPublished(
Instrument
instrument, MeterListener meterListener, object? meterScope)
538
Instrument
instrument, double value,
Linux\LinuxCountersTests.cs (1)
103
var samples = new List<(
Instrument
instrument, long value)>();
Linux\LinuxUtilizationProviderTests.cs (3)
65
var samples = new List<(
Instrument
instrument, double value)>();
134
var samples = new List<(
Instrument
instrument, double value)>();
249
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 (76)
System\Diagnostics\Metrics\AggregationManager.cs (20)
22
private readonly List<Predicate<
Instrument
>> _instrumentConfigFuncs = new();
27
private Dictionary<
Instrument
, bool> _instruments = new();
28
private readonly ConcurrentDictionary<
Instrument
, InstrumentState> _instrumentStates = new();
37
private readonly Action<
Instrument
, LabeledAggregationStatistics, InstrumentState?> _collectMeasurement;
40
private readonly Action<
Instrument
, InstrumentState> _beginInstrumentMeasurements;
41
private readonly Action<
Instrument
, InstrumentState> _endInstrumentMeasurements;
42
private readonly Action<
Instrument
, InstrumentState?> _instrumentPublished;
56
Action<
Instrument
, LabeledAggregationStatistics, InstrumentState?> collectMeasurement,
59
Action<
Instrument
, InstrumentState> beginInstrumentMeasurements,
60
Action<
Instrument
, InstrumentState> endInstrumentMeasurements,
61
Action<
Instrument
, InstrumentState?> instrumentPublished,
116
private void Include(Predicate<
Instrument
> instrumentFilter)
145
private void CompletedMeasurements(
Instrument
instrument, object? cookie)
153
private void PublishedInstrument(
Instrument
instrument, MeterListener _)
333
private void RemoveInstrumentState(
Instrument
instrument)
338
private InstrumentState? GetInstrumentState(
Instrument
instrument)
344
foreach (Predicate<
Instrument
> filter in _instrumentConfigFuncs)
367
internal InstrumentState? BuildInstrumentState(
Instrument
instrument)
379
private Func<Aggregator?>? GetAggregatorFactory(
Instrument
instrument)
510
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 (4)
24
_tags =
Instrument
.EmptyTags;
35
_tags = tags?.ToArray() ??
Instrument
.EmptyTags;
53
_tags =
Instrument
.EmptyTags;
86
_tags =
Instrument
.EmptyTags;
System\Diagnostics\Metrics\Meter.cs (23)
19
private List<
Instrument
> _instruments = new List<
Instrument
>();
20
private Dictionary<string, List<
Instrument
>> _nonObservableInstrumentsCache = new();
93
lock (
Instrument
.SyncObject)
499
List<
Instrument
>? instruments = null;
501
lock (
Instrument
.SyncObject)
511
_instruments = new List<
Instrument
>();
521
foreach (
Instrument
instrument in instruments)
528
private static
Instrument
? GetCachedInstrument(List<
Instrument
> instrumentList, Type instrumentType, string? unit, string? description, IEnumerable<KeyValuePair<string, object?>>? tags)
531
foreach (
Instrument
instrument in instrumentList)
544
private
Instrument
GetOrCreateInstrument<T>(Type instrumentType, string name, string? unit, string? description, IEnumerable<KeyValuePair<string, object?>>? tags, Func<
Instrument
> instrumentCreator)
546
List<
Instrument
>? instrumentList;
552
instrumentList = new List<
Instrument
>();
562
Instrument
? cachedInstrument = GetCachedInstrument(instrumentList, instrumentType, unit, description, tags);
569
Instrument
newInstrument = instrumentCreator.Invoke();
575
Instrument
? cachedInstrument = GetCachedInstrument(instrumentList, instrumentType, unit, description, tags);
589
internal bool AddInstrument(
Instrument
instrument)
601
internal static List<
Instrument
>? GetPublishedInstruments()
603
List<
Instrument
>? instruments = null;
607
instruments = new List<
Instrument
>();
611
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)
831
private static void TransmitMetricValue(
Instrument
instrument, LabeledAggregationStatistics stats, string sessionId, InstrumentState? instrumentState)