<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="10.0.0-preview.6.25358.103" />

InstrumentAdvice<T>

public sealed class InstrumentAdvice<T> where T : struct
Contains configuration settings advised to be used by metrics consumers when recording measurements for a given Instrument<T>.
using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime.CompilerServices; namespace System.Diagnostics.Metrics { public sealed class InstrumentAdvice<T> where T : struct { private readonly ReadOnlyCollection<T> _HistogramBucketBoundaries; [Nullable(new byte[] { 2, 0 })] public IReadOnlyList<T> HistogramBucketBoundaries { [return: Nullable(new byte[] { 2, 0 })] get { return _HistogramBucketBoundaries; } [param: Nullable(new byte[] { 2, 0 })] set { ArgumentNullException.ThrowIfNull(value, "value"); List<T> list = new List<T>(value); if (!IsSortedAndDistinct(list)) throw new ArgumentException(System.SR.InvalidHistogramExplicitBucketBoundaries, "value"); _HistogramBucketBoundaries = new ReadOnlyCollection<T>(list); } } public InstrumentAdvice() { Instrument.ValidateTypeParameter<T>(); } private static bool IsSortedAndDistinct(List<T> values) { Comparer<T> default = Comparer<T>.Default; for (int i = 1; i < values.Count; i++) { if (default.Compare(values[i - 1], values[i]) >= 0) return false; } return true; } } }