-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[receiver/awsfirehose] Refactor to use pdata unmarshaler interfaces #37361
Open
axw
wants to merge
9
commits into
open-telemetry:main
Choose a base branch
from
axw:firehose-unmarshal-record
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Benchmark the entire HTTP request handling to avoid fixating on irrelevant details.
92eb526
to
3e3d392
Compare
The internal unmarshalers now implement plog.Unmarshaler and pmetric.Unmarshaler. This will enable extracting them later as encoding extensions; for now they remain embedded within the receiver. As a result of the interface change, the unmarshalers now unmarshal a single record at a time, which means we cannot merge resources/metrics as we go, but only after each record. This also fixes a bug in the cwmetrics unmarshaller where the unit of a metric was not considered part of its identity, and so two metrics that differed only by unit would be merged. Optimise all the things: - Use json-iterator for decoding JSON - Use klauspost/compress for decompressing gzip - Pool gzip readers - Remove pointer type from cwMetricValue to avoid allocation - Don't read the whole request body into memory - Reuse buffer for decoding base64; decode as we go - Implement more efficient metrics merging
3e3d392
to
941cbef
Compare
Aneurysm9
reviewed
Feb 5, 2025
receiver/awsfirehosereceiver/internal/unmarshaler/cwlog/unmarshaler.go
Outdated
Show resolved
Hide resolved
receiver/awsfirehosereceiver/internal/unmarshaler/cwlog/unmarshaler.go
Outdated
Show resolved
Hide resolved
receiver/awsfirehosereceiver/internal/unmarshaler/cwlog/unmarshaler.go
Outdated
Show resolved
Hide resolved
receiver/awsfirehosereceiver/internal/unmarshaler/cwlog/unmarshaler.go
Outdated
Show resolved
Hide resolved
receiver/awsfirehosereceiver/internal/unmarshaler/cwmetricstream/unmarshaler.go
Outdated
Show resolved
Hide resolved
receiver/awsfirehosereceiver/internal/unmarshaler/cwmetricstream/unmarshaler.go
Outdated
Show resolved
Hide resolved
receiver/awsfirehosereceiver/internal/unmarshaler/otlpmetricstream/unmarshaler.go
Outdated
Show resolved
Hide resolved
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
This would imply corruption at the gzip level, since the gzip reader is working off an in-memory buffer. Unlikely, but swallow the error to keep it in line with existing code.
Aneurysm9
approved these changes
Feb 6, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Refactor unmarshallers to fit into the encoding framework.
The internal unmarshallers now implement
plog.Unmarshaler
andpmetric.Unmarshaler
. This will enable us to use encoding extensions in a followup, and will enable us to extract the unmarshallers later as encoding extensions.As a result of the interface change, the unmarshallers now unmarshal a single record at a time, which means we cannot merge resources/metrics as we go, and only within each record. This impacts performance, so to offset that we implement various optimisations:
There are more optimisations we can make to reduce memory allocations, e.g. avoid reflection when decoding JSON.
There's a fix for a subtle bug in the cwmetrics unmarshaller where the unit of a metric was not considered part of its identity, and so two metrics that differed only by unit would be merged.
Link to tracking issue
Preparation for #37113
Testing
Documentation
N/A