-
Notifications
You must be signed in to change notification settings - Fork 772
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 for Histograms #2657
Update MetricPoint for Histograms #2657
Conversation
src/OpenTelemetry.Exporter.Prometheus/Implementation/PrometheusSerializerExt.cs
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## main #2657 +/- ##
==========================================
- Coverage 81.33% 81.32% -0.02%
==========================================
Files 246 247 +1
Lines 8659 8670 +11
==========================================
+ Hits 7043 7051 +8
- Misses 1616 1619 +3
|
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.
Nice! This looks so much better 😀. Just left some minor comments.
} | ||
else | ||
{ | ||
throw new InvalidOperationException($"{nameof(this.GetBucketCounts)} is not supported for this metric type."); |
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.
Should we really throw here? 🤔
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.
If we do want to throw, NotSupportedException
is probably more appropriate.
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.
I think we should throw here. If we don't there would be no way for exporters to know if they are working correctly as they would just get some default values which is not the actual metric value.
Assert.Null(histogramPoint.ExplicitBounds); | ||
Assert.Equal(7, count); | ||
|
||
Assert.Throws<InvalidOperationException>(() => histogramPoint.GetBucketCounts()); |
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.
I think we should really evaluate if we want to throw in these getters, as this might be unexpected. Specially since now the behavior is changed.
} | ||
else | ||
{ | ||
throw new InvalidOperationException($"{nameof(this.GetHistogramSum)} is not supported for this metric type."); |
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.
Whatever we define (throw or just a log), I think it would be good to log the aggType
or the metric type?
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.
AggType
is private
. We can create a mapping of AggType
to MetricType
and add that here. This could be done in a follow-up PR.
{ | ||
if (this.aggType == AggregationType.Histogram || this.aggType == AggregationType.HistogramSumCount) | ||
{ | ||
return this.histogramMeasurements.Count; |
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.
we can simply use the long and double values from MetricPoint itself. No need to add them to HistogramMeasurements.
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.
@CodeBlanch was planning to see if we can custom layout to overlap the long/double field. That'd mean we'd be able to still need one of them inside HistogramMeasurement
.
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.
can be addressed as a follow up.
OpenTelemetry.Metrics.MetricPoint.DoubleValue.get -> double | ||
OpenTelemetry.Metrics.MetricPoint.EndTime.get -> System.DateTimeOffset | ||
OpenTelemetry.Metrics.MetricPoint.ExplicitBounds.get -> double[] | ||
OpenTelemetry.Metrics.MetricPoint.GetBucketCounts() -> long[] |
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.
as a follow up we need to do something similar to whats done for Tags. (readonly something)
@@ -133,6 +133,9 @@ public static int WriteMetric(byte[] buffer, int cursor, Metric metric) | |||
} | |||
|
|||
// Histogram sum | |||
var count = metricPoint.GetHistogramCount(); |
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.
Do we need to declare these variables here, or just use them inline?
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.
Fixed this in #2664
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.
LGTM with minor suggestions/comments.
Partially fixes #2633
Changes
HistogramMeasurements
for Hisotgram related dataGetBucketCounts
,GetExplicitBounds
,GetHistogramCount
, andGetHistogramSum
Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes