chore: pass SendDataBuilderInfo instead of SendData until flush time#745
Merged
chore: pass SendDataBuilderInfo instead of SendData until flush time#745
Conversation
1ae5c33 to
d460d15
Compare
ad6fad4 to
20c90e4
Compare
d460d15 to
d3c142e
Compare
20c90e4 to
622a2d6
Compare
astuyve
reviewed
Jul 16, 2025
lym953
commented
Jul 16, 2025
Comment on lines
+10
to
+22
| // Bundle SendDataBuilder with payload size because SendDataBuilder doesn't | ||
| // expose a getter for the size | ||
| pub struct SendDataBuilderInfo { | ||
| pub builder: SendDataBuilder, | ||
| pub size: usize, | ||
| } | ||
|
|
||
| impl SendDataBuilderInfo { | ||
| pub fn new(builder: SendDataBuilder, size: usize) -> Self { | ||
| Self { builder, size } | ||
| } | ||
| } | ||
|
|
Contributor
Author
There was a problem hiding this comment.
Adding SendDataBuilderInfo in trace_aggregator.rs because this is where the size is consumed. Let me know if you have a better place.
| if let Some(payload_info) = self.queue.pop_front() { | ||
| // TODO(duncanista): revisit if this is bigger than limit | ||
| let payload_size = payload.len(); | ||
| let payload_size = payload_info.size; |
Contributor
Author
There was a problem hiding this comment.
size is consumed here
| while !trace_builders.is_empty() { | ||
| let traces: Vec<_> = trace_builders | ||
| .into_iter() | ||
| .map(SendDataBuilder::build) |
Contributor
Author
There was a problem hiding this comment.
build() is called here
| let mut send_data = send_data_builder | ||
| let builder = SendDataBuilder::new(body_size, payload, header_tags, &endpoint) | ||
| .with_compression(Compression::Zstd(6)) | ||
| .build(); |
Contributor
Author
There was a problem hiding this comment.
build() is no longer called here
| None, | ||
| )); | ||
|
|
||
| SendDataBuilderInfo::new(builder, body_size) |
Contributor
Author
There was a problem hiding this comment.
SendDataBuilderInfo is constructed here
astuyve
approved these changes
Jul 16, 2025
531ce59 to
84cadbf
Compare
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.
Background
Right now
SendDatais passed around across channels.This PR
Instead of passing
SendData, passSendDataBuilderInfo, which bundlesSendDataBuilderand payload size. Just before flush, callSendDataBuilder.build()to buildSendData.Motivation
DataDog/libdatadog#1140 (comment) It is suggested that the function
set_api_key()shouldn't be added onSendData, but should be added onSendDataBuilder. Because need to callset_api_key()just before flush, we need to make sure the object isSendDataBuilderinstead ofSendDatauntil flush time.And because we need payload size in Trace Aggregator, and
SendDataBuilderdoesn't expose this field, we need to pass it explicitly along withSendDataBuilder.Next steps
Update #717 #732 so that
get_api_key()is called just before flush.Dependency
DataDog/libdatadog#1140