-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[awsemfexporter] Add check for unhandled metric data types #1493
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
[awsemfexporter] Add check for unhandled metric data types #1493
Conversation
Tagging @mxiamxia @wyTrivail @hdj630 |
ca0bf5b
to
2e72cfe
Compare
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! Thanks.
Codecov Report
@@ Coverage Diff @@
## master #1493 +/- ##
=======================================
Coverage 88.72% 88.72%
=======================================
Files 344 344
Lines 16844 16857 +13
=======================================
+ Hits 14944 14957 +13
Misses 1434 1434
Partials 466 466
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -215,22 +220,30 @@ func getCWMetrics(metric *pdata.Metric, namespace string, instrumentationLibName | |||
dps = DoubleDataPointSlice{metric.DoubleSum().DataPoints()} | |||
case pdata.MetricDataTypeDoubleHistogram: | |||
dps = DoubleHistogramDataPointSlice{metric.DoubleHistogram().DataPoints()} | |||
default: | |||
config.logger.Warn( |
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.
.debug
level I think, this will be too spammy right?
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.
Hey @anuraaga, thanks for the feedback! Since this is an edge case, it shouldn't happen often, and we do want to alert the customer that this is happening vs just having it in the debug level. I'm happy to turn this down to debug
if down the road this edge case is occurring more frequently than we think. :)
cc: @mxiamxia
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.
Please fix this in a followup PR if needed
* Fix log adapter in Prometheus receiver * Add comments to new functions * Fix lint error * Improve code coverage * Recognize message, more tests * Define constants
Description:
There is an edge case where the incoming metric might not fit one of the following
pdata
data types:MetricDataTypeIntGauge
MetricDataTypeDoubleGauge
MetricDataTypeIntSum
MetricDataTypeDoubleSum
MetricDataTypeDoubleHistogram
In that case, there will be a nil pointer reference error. To fix this bug, this PR checks for any unhandled metric data types and logs out a warning message instead of panicking. With this change, we will now get the following warning messages for unhandled data types:
Additionally, a
logger
was added to theConfig
struct as a private field for access by functions to log out warning messages.Testing:
Unit tests were added and ran successfully.