-
Notifications
You must be signed in to change notification settings - Fork 13
chore: pass SendDataBuilderInfo instead of SendData until flush time #745
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
1ae5c33
to
d460d15
Compare
ad6fad4
to
20c90e4
Compare
d460d15
to
d3c142e
Compare
20c90e4
to
622a2d6
Compare
// 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 } | ||
} | ||
} | ||
|
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.
Adding SendDataBuilderInfo
in trace_aggregator.rs
because this is where the size
is consumed. Let me know if you have a better place.
// TODO(duncanista): revisit if this is bigger than limit | ||
let payload_size = payload.len(); | ||
let payload_size = payload_info.size; |
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.
size
is consumed here
while !trace_builders.is_empty() { | ||
let traces: Vec<_> = trace_builders | ||
.into_iter() | ||
.map(SendDataBuilder::build) |
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.
build()
is called here
.with_compression(Compression::Zstd(6)) | ||
.build(); |
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.
build()
is no longer called here
None, | ||
)); | ||
|
||
SendDataBuilderInfo::new(builder, body_size) |
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.
SendDataBuilderInfo
is constructed here
531ce59
to
84cadbf
Compare
Background
Right now
SendData
is passed around across channels.This PR
Instead of passing
SendData
, passSendDataBuilderInfo
, which bundlesSendDataBuilder
and 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 isSendDataBuilder
instead ofSendData
until flush time.And because we need payload size in Trace Aggregator, and
SendDataBuilder
doesn'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