fix(otlp): use body.len() for body_size and fix empty-traces check#1093
Draft
lym953 wants to merge 3 commits intoyiming.luo/drop-traces-2from
Draft
fix(otlp): use body.len() for body_size and fix empty-traces check#1093lym953 wants to merge 3 commits intoyiming.luo/drop-traces-2from
lym953 wants to merge 3 commits intoyiming.luo/drop-traces-2from
Conversation
Contributor
Author
|
@duncanista In your PR #654 there's a commit use size_of_val for payload, instead of .encoded_len(). Do you remember why? |
size_of_val(&traces) returned the 24-byte stack size of the Vec regardless of content, so body_size was always a meaningless constant and the empty-trace guard never fired. Use body.len() for the actual OTLP wire byte count and traces.is_empty() for the empty-trace guard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
c651cfe to
4fa9dca
Compare
Contributor
|
@lym953 I remember it was because it was "more correct", I think after using prost, the method for len wasn't available on the message itself, it would crash |
Contributor
Author
|
@duncanista Thanks. From my test, I didn't see any problem using |
This file contains hidden or 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
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.
Summary
size_of_val(&traces)returned the 24-byte stack size of theVecregardless of content, sobody_sizewas always a meaningless constant and the empty-trace guard (if body_size == 0) never firedbody.len()(raw OTLP wire bytes) forbody_sizeandtraces.is_empty()for the empty-trace guardTest plan
test_v1_traces_empty_request_returns_error: verifies that an OTLP request with no spans returns 500 (previously the guard never fired)test_v1_traces_body_size_equals_request_body_len: verifies thatbody_sizepassed toprocess_tracesequalsbody.len()🤖 Generated with Claude Code