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

[exporter/awscloudwatchlogs] Inf/NaN attribute values will cause JSON marshal failure #30332

Closed
bryan-aguilar opened this issue Jan 8, 2024 · 5 comments

Comments

@bryan-aguilar
Copy link
Contributor

bryan-aguilar commented Jan 8, 2024

Reading this section of code made me wonder what would happen there was an attribute with Double type and Math.Inf() value.

With slightly modification to your PR I saw that the JSON marshaling would fail.

func testScope() pcommon.InstrumentationScope {
	scope := pcommon.NewInstrumentationScope()
	scope.SetName("test-scope")
	scope.SetVersion("1.0.0")
	scope.Attributes().PutStr("scope-attr", "value")
	scope.Attributes().PutDouble("test-inf", math.Inf(0))
	return scope
}


=== RUN   TestLogToCWLog
=== RUN   TestLogToCWLog/basic
    exporter_test.go:249: logToCWLog() error = json: unsupported value: +Inf, wantErr false
--- FAIL: TestLogToCWLog (0.00s)
    --- FAIL: TestLogToCWLog/basic (0.00s)

We have seen this JSON marshaling failure before in the EMF Exporter when a metric is processed with Inf or NaN values. In the EMF Exporter we completely drop the metric.

I think this "issue" is outside the scope of the PR but should at least be noted somewhere. At minumum I think this affects the awsemfexporter and awscloudwatchlogs exporter. I think this would also affect any exporter that does JSON marshaling before export. Having to clean a set of attributes for each log seems computationally expensive so we should verify the cost of doing so before moving forward with a very simple fix (checking for and removing all NaN/Inf) values.

Originally posted by @bryan-aguilar in #30316 (comment)

@bryan-aguilar bryan-aguilar added priority:p3 Lowest exporter/awscloudwatchlogs awscloudwatchlogs exporter exporter/awsemf awsemf exporter labels Jan 8, 2024
Copy link
Contributor

github-actions bot commented Jan 8, 2024

Pinging code owners for exporter/awscloudwatchlogs: @boostchicken @bryan-aguilar @rapphil. See Adding Labels via Comments if you do not have permissions to add labels yourself.

Copy link
Contributor

github-actions bot commented Jan 8, 2024

Pinging code owners for exporter/awsemf: @Aneurysm9 @shaochengwang @mxiamxia @bryan-aguilar. See Adding Labels via Comments if you do not have permissions to add labels yourself.

@bryan-aguilar
Copy link
Contributor Author

I am not sure what the correct solution is here, but I would like this issue to exist just in case any user runs into these errors with the awsemf or awscloudwatchlogs exporter.

Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Mar 11, 2024
Copy link
Contributor

This issue has been closed as inactive because it has been stale for 120 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant