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] Feat: include scope in log record of cloudwatchlogs exporter #30316

Conversation

rapphil
Copy link
Contributor

@rapphil rapphil commented Jan 6, 2024

Description: Include the instrumentation scope in the log records exported by the cloudwatchlogs expoter

Link to tracking Issue: #29884

Testing: Unit tests were added.

Include the instrumentation scope in the log records exported by the cloudwatchlogs expoter

Signed-off-by: Raphael Silva <[email protected]>
@github-actions github-actions bot added the exporter/awscloudwatchlogs awscloudwatchlogs exporter label Jan 6, 2024
Signed-off-by: Raphael Silva <[email protected]>
@rapphil rapphil marked this pull request as ready for review January 6, 2024 02:10
@rapphil rapphil requested a review from bryan-aguilar as a code owner January 6, 2024 02:10
@rapphil rapphil requested a review from a team January 6, 2024 02:10
Signed-off-by: Raphael Silva <[email protected]>
@rapphil rapphil changed the title Feat: include scope in log record of cloudwatchlogs exporter [exporter/awscloudwatchlogs] Feat: include scope in log record of cloudwatchlogs exporter Jan 7, 2024
Comment on lines +230 to 235
Attributes: attrsValue(scope.Attributes()),
}
body.Scope = scopeBody
}

bodyJSON, err = json.Marshal(body)
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

@bryan-aguilar bryan-aguilar added ready to merge Code review completed; ready to merge by maintainers and removed ready to merge Code review completed; ready to merge by maintainers labels Jan 9, 2024
@bogdandrutu bogdandrutu merged commit aa2e9f7 into open-telemetry:main Jan 10, 2024
96 checks passed
@github-actions github-actions bot added this to the next release milestone Jan 10, 2024
cparkins pushed a commit to AmadeusITGroup/opentelemetry-collector-contrib that referenced this pull request Jan 10, 2024
…udwatchlogs exporter (open-telemetry#30316)

**Description:** Include the instrumentation scope in the log records
exported by the cloudwatchlogs expoter

**Link to tracking Issue:** open-telemetry#29884

**Testing:** Unit tests were added.

---------

Signed-off-by: Raphael Silva <[email protected]>
Co-authored-by: bryan-aguilar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/awscloudwatchlogs awscloudwatchlogs exporter ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants