-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix: Fix push stats calculation #19319
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
Conversation
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.
Looks good, just a couple small things.
Also, in response to setting isInternalStream
to true even if there is only one internal stream in the whole request, I think your refactor is better as it keeps more state local to the function, but in practice a push req should never have a mix of internal and tenant provided streams. The internal streams come from us, and never contain tenant provided streams, so if a req does have both it means the tenant is doing something nefarious.
} | ||
|
||
shouldDiscoverServiceName := len(discoverServiceName) > 0 && !stats.IsInternalStream | ||
shouldDiscoverServiceName := len(discoverServiceName) > 0 |
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.
why remove the extra check? we shouldn't be running service name detection on payloads with internal streams
&logproto.PushRequest{ | ||
Streams: []logproto.Stream{ | ||
{ | ||
Labels: `{ "foo"="bar2", "environment"="prod" }`, // extra spaces are important |
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'm assuming the extra spaces are important for the assertion on stream label size? I think that's worth adding to the comment
What this PR does / why we need it:
Current calculation of push
Stats
inParseLokiRequest
is based on data that might not be available later inPushParserWrapper
. This leads to mismatched calculations in AdaptiveLogs wrapper and it returns negative stats as a result.pushStats.StreamLabelsSize
is a size of labels BEFORE they are sanitized (only relevant to protobuf payloads). This is not a big deal, unless a new label is added for service name. Then labels are modified inside the original stream object and it is impossible to recover the original size (inPushParserWrapper
).util.StructuredMetadataSize
was not used in the wrapper, that led to mismatched numbers for structured metadata.isInternalStream
is set to true even if there is only one internal stream in the whole request. Might affect other streams in the same request.Extracted
CalculateStreamsStats
so that it can be reused in a wrapper. It takes a push request and calculates all stream stats for it. Adaptive Logs now can drop some streams/entries from a request and just call this method in order to get new stats, instead of subtracting values for dropped items.Minor: also added some comments, and fixed few typos.
Special notes for your reviewer:
There will be a follow up PR for GEL.
Checklist
CONTRIBUTING.md
guide (required)feat
PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.md
deprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR