-
Notifications
You must be signed in to change notification settings - Fork 3k
[GCP encoding] Use JSON struct for all common fields and improve performance #41467
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
[GCP encoding] Use JSON struct for all common fields and improve performance #41467
Conversation
@alexvanboxel please take a look as codeowner |
Please @alexvanboxel, can you take a look? Thanks :) |
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.
This is a big commit.
extension/encoding/googlecloudlogentryencodingextension/log_proto_payload_test.go
Show resolved
Hide resolved
@atoulme can you merge this PR now that it is approved? Thank you |
) | ||
|
||
var json = jsoniter.ConfigCompatibleWithStandardLibrary | ||
// See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry | ||
type logEntry struct { |
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.
Is there a reason to not use the upstream definitions?
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.
Sorry, what do you mean?
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 understand what you mean now.
There are fields missing from the definitions: app hub and error groups, for example
Please resolve conflicts |
@atoulme conflicts are fixed |
This PR transfers ownership of the GCP encoding. My contributions: - open-telemetry#41087 - open-telemetry#41446 - open-telemetry#41467 - open-telemetry#41137
…ormance (open-telemetry#41467) #### Description This PR uses a JSON struct now instead of `map[string]any`, as we know what to expect from a GCP log entry. This causes significant performance improvement: ``` goos: linux goarch: amd64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/googlecloudlogentryencodingextension cpu: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ Test-16 19.907µ ± 3% 6.583µ ± 4% -66.93% (p=0.000 n=10) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ Test-16 13.310Ki ± 0% 5.326Ki ± 0% -59.98% (p=0.000 n=10) │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ Test-16 340.00 ± 0% 90.00 ± 0% -73.53% (p=0.000 n=10) ``` The main goal of using a JSON struct is so that we can use semantic conventions, like mentioned in issue open-telemetry#41087. There are also two breaking changes, since the code implemented before was not working correctly for these cases: - Logs also have now observedTimeUnixNano and flags - If there is an error handling the log, just return the error and empty logs for ALL cases. Before this behavior was inconsistent: either the error was ignored ([here](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/5943f5a933843e6f81bed28a05e2f33d8c1fc485/extension/encoding/googlecloudlogentryencodingextension/extension.go#L86)), or it would stop the logs from being received ([here](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/5943f5a933843e6f81bed28a05e2f33d8c1fc485/extension/encoding/googlecloudlogentryencodingextension/extension.go#L94)) <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Relates to open-telemetry#41087 (comment). <!--Describe what testing was performed and which tests were added.--> #### Testing Unit tests fixed. <!--Describe the documentation added.--> #### Documentation N/A.
Description
This PR uses a JSON struct now instead of
map[string]any
, as we know what to expect from a GCP log entry. This causes significant performance improvement:The main goal of using a JSON struct is so that we can use semantic conventions, like mentioned in issue #41087.
There are also two breaking changes, since the code implemented before was not working correctly for these cases:
Link to tracking issue
Relates to #41087 (comment).
Testing
Unit tests fixed.
Documentation
N/A.