You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(traces): update payload size after dropping traces (#1091)
## This PR
After dropping sampled-out traces, recompute `body_size`. This ensures
the `TraceAggregator`'s 3.2 MB batch limit is evaluated against only the
data that will actually be sent to the backend.
Upgrades the version of some external crates because those are the
versions used in libdatadog.
## Testing
- Unit tests
## Note
The recomputed size uses the protobuf encoded payload size, different
from the original size, computed from: (from Claude)
> - Datadog tracer path: src/traces/trace_agent.rs:506 — body_size is
the first element of the tuple returned by
get_traces_from_request_body() / get_v05_traces_from_request_body(),
which is the raw HTTP request
body byte count (msgpack-encoded bytes).
> - OTLP path: src/otlp/agent.rs:167 — let body_size =
size_of_val(&traces) where traces is a TracerPayloadCollection, giving
only the stack size of the Rust enum (~32 bytes).
The new approach be more accurate because it's computed at a later point
for the size of protobuf data, which is what's finally sent to Datadog.
By the way, the size doesn't need to be accurate. An approximate size is
good enough. See:
https://github.com/DataDog/libdatadog/blob/3f3efefb2ff45d7a5491b770480396d001b87631/libdd-trace-utils/src/send_data/mod.rs#L148
Also here are some sample logs (logging node not included in the PR)
showing the different sizes computed in different ways:
> body_size (original): 582, body_size (encoded_len): 1355
> body_size (original): 373, body_size (encoded_len): 1269
> body_size (original): 336, body_size (encoded_len): 899
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
cookie,https://github.com/SergioBenitez/cookie-rs,MIT OR Apache-2.0,"Sergio Benitez <sb@sergio.bz>, Alex Crichton <alex@alexcrichton.com>"
@@ -144,6 +147,7 @@ powerfmt,https://github.com/jhpratt/powerfmt,MIT OR Apache-2.0,Jacob Pratt <jaco
144
147
ppv-lite86,https://github.com/cryptocorrosion/cryptocorrosion,MIT OR Apache-2.0,The CryptoCorrosion Contributors
145
148
proc-macro2,https://github.com/dtolnay/proc-macro2,MIT OR Apache-2.0,"David Tolnay <dtolnay@gmail.com>, Alex Crichton <alex@alexcrichton.com>"
146
149
proc-macro2-diagnostics,https://github.com/SergioBenitez/proc-macro2-diagnostics,MIT OR Apache-2.0,Sergio Benitez <sb@sergio.bz>
150
+
proptest,https://github.com/proptest-rs/proptest,MIT OR Apache-2.0,Jason Lingle
147
151
prost,https://github.com/tokio-rs/prost,Apache-2.0,"Dan Burkert <dan@danburkert.com>, Lucio Franco <luciofranco14@gmail.com>, Casper Meijn <casper@meijn.net>, Tokio Contributors <team@tokio.rs>"
148
152
prost-derive,https://github.com/tokio-rs/prost,Apache-2.0,"Dan Burkert <dan@danburkert.com>, Lucio Franco <luciofranco14@gmail.com>, Casper Meijn <casper@meijn.net>, Tokio Contributors <team@tokio.rs>"
149
153
prost-types,https://github.com/tokio-rs/prost,Apache-2.0,"Dan Burkert <dan@danburkert.com>, Lucio Franco <luciofranco14@gmail.com>, Casper Meijn <casper@meijn.net>, Tokio Contributors <team@tokio.rs>"
@@ -158,6 +162,7 @@ r-efi,https://github.com/r-efi/r-efi,MIT OR Apache-2.0 OR LGPL-2.1-or-later,The
158
162
rand,https://github.com/rust-random/rand,MIT OR Apache-2.0,"The Rand Project Developers, The Rust Project Developers"
159
163
rand_chacha,https://github.com/rust-random/rand,MIT OR Apache-2.0,"The Rand Project Developers, The Rust Project Developers, The CryptoCorrosion Contributors"
160
164
rand_core,https://github.com/rust-random/rand,MIT OR Apache-2.0,"The Rand Project Developers, The Rust Project Developers"
165
+
rand_xorshift,https://github.com/rust-random/rngs,MIT OR Apache-2.0,"The Rand Project Developers, The Rust Project Developers"
0 commit comments