-
Notifications
You must be signed in to change notification settings - Fork 775
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
Update MetricPoint HistogramMeasurements #2664
Changes from 3 commits
7f82ce0
4b8d421
22b0d85
9ba6bb7
e41e84e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// <copyright file="HistogramMeasurement.cs" company="OpenTelemetry Authors"> | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
namespace OpenTelemetry.Metrics | ||
{ | ||
public readonly struct HistogramMeasurement | ||
{ | ||
internal HistogramMeasurement(double explicitBound, long bucketCount) | ||
{ | ||
this.ExplicitBound = explicitBound; | ||
this.BucketCount = bucketCount; | ||
} | ||
|
||
public double ExplicitBound { get; } | ||
|
||
public long BucketCount { get; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -16,7 +16,7 @@ | |||||
|
||||||
namespace OpenTelemetry.Metrics | ||||||
{ | ||||||
internal class HistogramMeasurements | ||||||
public class HistogramMeasurements | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a If it is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HistogramMetricPointBucket is correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
{ | ||||||
internal readonly long[] BucketCounts; | ||||||
|
||||||
|
@@ -41,5 +41,44 @@ internal HistogramMeasurements(double[] histogramBounds) | |||||
this.AggregatedBucketCounts = histogramBounds != null ? new long[histogramBounds.Length + 1] : null; | ||||||
this.LockObject = new object(); | ||||||
} | ||||||
|
||||||
public Enumerator GetEnumerator() => new(this); | ||||||
|
||||||
public struct Enumerator | ||||||
{ | ||||||
private readonly bool isHistogramSumCount; | ||||||
private readonly int numberOfBuckets; | ||||||
private readonly int numberofExplicitBounds; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you look at the original one I did, I had a At the least, I think we can remove public bool MoveNext()
{
if (this.index < this.numberOfBuckets) ...should be enough (I think)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have removed |
||||||
private readonly HistogramMeasurements histogramMeasurements; | ||||||
private int index; | ||||||
|
||||||
internal Enumerator(HistogramMeasurements histogramMeasurements) | ||||||
{ | ||||||
this.histogramMeasurements = histogramMeasurements; | ||||||
this.index = 0; | ||||||
this.Current = default; | ||||||
this.isHistogramSumCount = histogramMeasurements.ExplicitBounds == null; | ||||||
this.numberOfBuckets = this.isHistogramSumCount ? default : histogramMeasurements.BucketCounts.Length; | ||||||
this.numberofExplicitBounds = this.isHistogramSumCount ? default : histogramMeasurements.ExplicitBounds.Length; | ||||||
} | ||||||
|
||||||
public HistogramMeasurement Current { get; private set; } | ||||||
|
||||||
public bool MoveNext() | ||||||
{ | ||||||
if (!this.isHistogramSumCount && this.index < this.numberOfBuckets) | ||||||
{ | ||||||
double explicitBound = this.index < this.numberofExplicitBounds | ||||||
? this.histogramMeasurements.ExplicitBounds[this.index] | ||||||
: double.PositiveInfinity; | ||||||
long bucketCount = this.histogramMeasurements.AggregatedBucketCounts[this.index]; | ||||||
this.Current = new HistogramMeasurement(explicitBound, bucketCount); | ||||||
this.index++; | ||||||
return true; | ||||||
} | ||||||
|
||||||
return false; | ||||||
} | ||||||
} | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the term "measurement" is misleading as it refers to the raw data point reported through the API. https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#measurement