Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[System.Diagnostics.DiagnosticSource] Implement metrics advice API #102524

Merged
merged 13 commits into from
Jun 20, 2024
Prev Previous commit
Next Next commit
Code review.
  • Loading branch information
CodeBlanch committed May 22, 2024
commit ea17f1734048230553a1593bb87451073f20e5c0
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,29 @@ public sealed class HistogramAdvice<T> where T : struct
/// <summary>
/// Constructs a new instance of <see cref="HistogramAdvice{T}"/>.
/// </summary>
/// <param name="explicitBucketBoundaries">
/// <para>Explicit bucket boundaries advised to be used with the histogram.</para>
/// <para>Notes:
/// <remarks>
/// Notes:
/// <list type="bullet">
/// <item>An empty set of bucket boundaries hints that the histogram by default should NOT contain buckets and should only track count and sum values.</item>
/// <item>A set of distinct increasing values for bucket boundaries hints that the histogram should use those for its default bucket configuration.</item>
/// </list>
/// </para>
/// </param>
/// </remarks>
/// <param name="explicitBucketBoundaries">Explicit bucket boundaries advised to be used with the histogram.</param>
public HistogramAdvice(IEnumerable<T> explicitBucketBoundaries)
CodeBlanch marked this conversation as resolved.
Show resolved Hide resolved
{
if (explicitBucketBoundaries is null)
{
throw new ArgumentNullException(nameof(explicitBucketBoundaries));
}

IReadOnlyList<T> explicitBucketBoundariesCopy = new ReadOnlyCollection<T>(new List<T>(explicitBucketBoundaries));
List<T> explicitBucketBoundariesCopy = new List<T>(explicitBucketBoundaries);

if (!IsSortedAndDistinct(explicitBucketBoundariesCopy))
CodeBlanch marked this conversation as resolved.
Show resolved Hide resolved
{
throw new ArgumentException(SR.InvalidHistogramExplicitBucketBoundaries, nameof(explicitBucketBoundaries));
}

ExplicitBucketBoundaries = explicitBucketBoundariesCopy;
ExplicitBucketBoundaries = new ReadOnlyCollection<T>(explicitBucketBoundariesCopy);
}

/// <summary>
Expand All @@ -54,7 +53,7 @@ public HistogramAdvice(IEnumerable<T> explicitBucketBoundaries)
/// </remarks>
public IReadOnlyList<T>? ExplicitBucketBoundaries { get; }

private static bool IsSortedAndDistinct(IReadOnlyList<T> values)
private static bool IsSortedAndDistinct(List<T> values)
{
Comparer<T> comparer = Comparer<T>.Default;

Expand Down
Loading