Skip to content

[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

Merged
merged 4 commits into from
Nov 6, 2020

Conversation

kohrapha
Copy link
Contributor

@kohrapha kohrapha commented Nov 4, 2020

Description:
There is an edge case where the incoming metric might not fit one of the following pdata data types:

  1. MetricDataTypeIntGauge
  2. MetricDataTypeDoubleGauge
  3. MetricDataTypeIntSum
  4. MetricDataTypeDoubleSum
  5. 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:

2020-11-04T20:48:41.812Z        WARN    [email protected]/metric_translator.go:224  Unhandled metric data type.      {"component_kind": "exporter", "component_type": "awsemf", "component_name": "awsemf", "DataType": "None", "Name": "latency", "Unit": "ms"}
2020-11-04T20:48:42.812Z        WARN    [email protected]/metric_translator.go:224  Unhandled metric data type.      {"component_kind": "exporter", "component_type": "awsemf", "component_name": "awsemf", "DataType": "None", "Name": "processedSpans", "Unit": "1"}

Additionally, a logger was added to the Config struct as a private field for access by functions to log out warning messages.

Testing:
Unit tests were added and ran successfully.

@kohrapha kohrapha requested a review from anuraaga as a code owner November 4, 2020 20:24
@kohrapha kohrapha requested a review from a team November 4, 2020 20:24
@kohrapha
Copy link
Contributor Author

kohrapha commented Nov 4, 2020

Tagging @mxiamxia @wyTrivail @hdj630

@kohrapha kohrapha force-pushed the kohrapha/unhandled-types branch from ca0bf5b to 2e72cfe Compare November 4, 2020 20:33
Copy link
Member

@mxiamxia mxiamxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks.

@codecov
Copy link

codecov bot commented Nov 5, 2020

Codecov Report

Merging #1493 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           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           
Flag Coverage Δ
integration 70.87% <ø> (+0.07%) ⬆️
unit 87.37% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
exporter/awsemfexporter/emf_exporter.go 97.64% <100.00%> (+0.05%) ⬆️
exporter/awsemfexporter/factory.go 100.00% <100.00%> (ø)
exporter/awsemfexporter/metric_translator.go 95.85% <100.00%> (+0.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 59a1114...2e72cfe. Read the comment docs.

@@ -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(
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Member

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

@bogdandrutu bogdandrutu merged commit 4da366a into open-telemetry:master Nov 6, 2020
dyladan referenced this pull request in dynatrace-oss-contrib/opentelemetry-collector-contrib Jan 29, 2021
* Fix log adapter in Prometheus receiver

* Add comments to new functions

* Fix lint error

* Improve code coverage

* Recognize message, more tests

* Define constants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants