-
Notifications
You must be signed in to change notification settings - Fork 13
Add functions to SendDataBuilder #1140
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1140 +/- ##
==========================================
+ Coverage 71.30% 71.38% +0.08%
==========================================
Files 343 343
Lines 52471 52547 +76
==========================================
+ Hits 37412 37511 +99
+ Misses 15059 15036 -23
🚀 New features to boost your workflow:
|
/// # Returns | ||
/// | ||
/// A mutable reference to the target endpoint. | ||
pub fn get_target_mut(&mut self) -> &mut Endpoint { |
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.
You really shouldn't be changing the target for the SendData object. This was just discussed with @shreyamalpani for #1134 and #1139
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.
Could you elaborate why? I don't see enough discussion in those two PRs.
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 reading the discussion in Slack https://dd.slack.com/archives/C01TCF143GB/p1752081547534679
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.
The send_with_retry module uses the endpoint. It's creates inconsistent behavior if the endpoint changes between retries.
The coalesce_send_data function sorts and deduplicates SendData based on endpoint properties. Changing the endpoints can lead to invalid deduplication and/or merged payloads being sent to the wrong destination.
send_data also has async code that uses the endpoint. Changing them can cause unexpected behavior and race conditions.
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.
Thanks for the context! Will it still be a concern if we only expose set_api_key()
? From a quick look at your code pointers, I see url
, timeout_ms
and test_token
used, but not api_key
.
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.
Changing the API key wouldn't impact the coalesce_send_data
function, but it would impact send_with_retry
which calls to_request_builder()
which uses the api key. Changing just the API key can cause another issue; I don't think it's a particularly good design, but send_data
determines whether to serialize to msgpack or proto based on the presence of an API key. If that switches from None
to Some
while the url remains the same it can lead to runtime errors.
If you need to lazily add the api key, I'd suggest adding a with_api_key()
function to SendDataBuilder.
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.
Sure! I limited all the changes to SendDataBuilder
. Could you take a look?
BenchmarksComparisonBenchmark execution time: 2025-07-15 20:16:46 Comparing candidate commit dbc4779 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 52 metrics, 2 unstable metrics. CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
Group 12
Group 13
BaselineOmitted due to size. |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
e5112d1
to
0b1b61e
Compare
What does this PR do?
Add functions to
SendDataBuilder
:with_api_key()
with_retry_strategy()
len()
is_empty()
Motivation
DataDog/datadog-lambda-extension#732 We want to lazily set api key in the
target
, i.e. leave it empty at creation time then set it later.As a result, we need to pass
SendDataBuilder
around in the codebase, instead of passingSendData
. Wherever we need to set/get data onSendData
right now, we need to do them onSendDataBuilder
instead.How to test the change?
Using the added test