Skip to content

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

Merged
merged 14 commits into from
Jul 16, 2025

Conversation

lym953
Copy link
Contributor

@lym953 lym953 commented Jul 10, 2025

What does this PR do?

Add functions to SendDataBuilder:

  • with_api_key()
  • with_retry_strategy()

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 passing SendData. Wherever we need to set data on SendData right now, we need to do it on SendDataBuilder instead.

How to test the change?

Using the added test

@codecov-commenter
Copy link

codecov-commenter commented Jul 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.36%. Comparing base (9c5753a) to head (6c28f32).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1140      +/-   ##
==========================================
+ Coverage   71.29%   71.36%   +0.07%     
==========================================
  Files         343      343              
  Lines       52536    52567      +31     
==========================================
+ Hits        37453    37516      +63     
+ Misses      15083    15051      -32     
Components Coverage Δ
datadog-crashtracker 43.89% <ø> (-0.03%) ⬇️
datadog-crashtracker-ffi 5.93% <ø> (ø)
datadog-alloc 98.73% <ø> (ø)
data-pipeline 89.38% <ø> (ø)
data-pipeline-ffi 88.36% <ø> (ø)
ddcommon 82.88% <ø> (ø)
ddcommon-ffi 69.66% <ø> (ø)
ddtelemetry 60.08% <ø> (ø)
ddtelemetry-ffi 21.32% <ø> (ø)
dogstatsd-client 83.26% <ø> (ø)
datadog-ipc 82.58% <ø> (ø)
datadog-profiling 77.13% <ø> (ø)
datadog-profiling-ffi 62.12% <ø> (ø)
datadog-sidecar 40.24% <ø> (ø)
datdog-sidecar-ffi 4.91% <ø> (ø)
spawn-worker 55.35% <ø> (ø)
tinybytes 90.96% <ø> (ø)
datadog-trace-normalization 98.24% <ø> (ø)
datadog-trace-obfuscation 94.17% <ø> (ø)
datadog-trace-protobuf 77.10% <ø> (ø)
datadog-trace-utils 89.72% <100.00%> (+0.52%) ⬆️
datadog-tracer-flare 75.14% <ø> (ø)
datadog-log 76.31% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lym953 lym953 marked this pull request as ready for review July 11, 2025 16:04
@lym953 lym953 requested review from a team as code owners July 11, 2025 16:04
@lym953 lym953 requested a review from a team July 11, 2025 16:05
/// # Returns
///
/// A mutable reference to the target endpoint.
pub fn get_target_mut(&mut self) -> &mut Endpoint {
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

@lym953 lym953 changed the title Add SendData.get_target_mut() Add SendData.set_api_key() Jul 14, 2025
@pr-commenter
Copy link

pr-commenter bot commented Jul 14, 2025

Benchmarks

Comparison

Benchmark execution time: 2025-07-16 16:52:13

Comparing candidate commit 6c28f32 in PR branch yiming.luo/send-data-get-mut-target with baseline commit 9c5753a in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 52 metrics, 2 unstable metrics.

Candidate

Candidate benchmark details

Group 1

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
write only interface execution_time 1.232µs 3.242µs ± 1.452µs 3.017µs ± 0.029µs 3.043µs 3.664µs 13.810µs 15.369µs 409.40% 7.367 55.591 44.69% 0.103µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
write only interface execution_time [3.041µs; 3.444µs] or [-6.209%; +6.209%] None None None

Group 2

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
normalization/normalize_trace/test_trace execution_time 246.094ns 258.564ns ± 14.938ns 250.662ns ± 3.557ns 273.394ns 284.913ns 298.427ns 323.811ns 29.18% 1.325 1.183 5.76% 1.056ns 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
normalization/normalize_trace/test_trace execution_time [256.494ns; 260.635ns] or [-0.801%; +0.801%] None None None

Group 3

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
tags/replace_trace_tags execution_time 2.388µs 2.422µs ± 0.021µs 2.416µs ± 0.005µs 2.423µs 2.487µs 2.497µs 2.504µs 3.66% 2.479 5.926 0.87% 0.001µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
tags/replace_trace_tags execution_time [2.419µs; 2.424µs] or [-0.121%; +0.121%] None None None

Group 4

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
ip_address/quantize_peer_ip_address_benchmark execution_time 4.999µs 5.094µs ± 0.052µs 5.114µs ± 0.041µs 5.136µs 5.166µs 5.168µs 5.176µs 1.20% -0.206 -1.435 1.02% 0.004µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
ip_address/quantize_peer_ip_address_benchmark execution_time [5.087µs; 5.101µs] or [-0.142%; +0.142%] None None None

Group 5

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
sql/obfuscate_sql_string execution_time 84.814µs 85.068µs ± 0.213µs 85.036µs ± 0.087µs 85.134µs 85.266µs 85.986µs 87.146µs 2.48% 5.595 46.976 0.25% 0.015µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
sql/obfuscate_sql_string execution_time [85.038µs; 85.098µs] or [-0.035%; +0.035%] None None None

Group 6

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
benching string interning on wordpress profile execution_time 143.447µs 144.289µs ± 0.377µs 144.234µs ± 0.142µs 144.382µs 144.953µs 145.715µs 147.037µs 1.94% 3.053 16.054 0.26% 0.027µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
benching string interning on wordpress profile execution_time [144.236µs; 144.341µs] or [-0.036%; +0.036%] None None None

Group 7

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... execution_time 205.774µs 206.292µs ± 0.355µs 206.248µs ± 0.144µs 206.402µs 206.698µs 207.087µs 209.259µs 1.46% 5.033 37.208 0.17% 0.025µs 1 200
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput 4778766.365op/s 4847511.221op/s ± 8275.050op/s 4848540.442op/s ± 3392.357op/s 4851666.208op/s 4854887.129op/s 4858627.985op/s 4859711.937op/s 0.23% -4.962 36.451 0.17% 585.134op/s 1 200
normalization/normalize_name/normalize_name/bad-name execution_time 18.214µs 18.292µs ± 0.080µs 18.266µs ± 0.019µs 18.290µs 18.487µs 18.541µs 18.669µs 2.20% 2.157 4.176 0.43% 0.006µs 1 200
normalization/normalize_name/normalize_name/bad-name throughput 53565243.602op/s 54668597.799op/s ± 235596.458op/s 54745456.837op/s ± 58011.376op/s 54797764.903op/s 54865879.317op/s 54889772.081op/s 54901417.061op/s 0.28% -2.137 4.066 0.43% 16659.185op/s 1 200
normalization/normalize_name/normalize_name/good execution_time 10.926µs 10.985µs ± 0.035µs 10.978µs ± 0.023µs 11.005µs 11.056µs 11.068µs 11.125µs 1.34% 0.778 0.693 0.31% 0.002µs 1 200
normalization/normalize_name/normalize_name/good throughput 89886538.674op/s 91034354.952op/s ± 286497.884op/s 91088947.667op/s ± 188663.965op/s 91242547.231op/s 91391669.808op/s 91523120.280op/s 91527595.570op/s 0.48% -0.759 0.637 0.31% 20258.460op/s 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... execution_time [206.243µs; 206.341µs] or [-0.024%; +0.024%] None None None
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput [4846364.379op/s; 4848658.064op/s] or [-0.024%; +0.024%] None None None
normalization/normalize_name/normalize_name/bad-name execution_time [18.281µs; 18.303µs] or [-0.060%; +0.060%] None None None
normalization/normalize_name/normalize_name/bad-name throughput [54635946.396op/s; 54701249.202op/s] or [-0.060%; +0.060%] None None None
normalization/normalize_name/normalize_name/good execution_time [10.980µs; 10.990µs] or [-0.044%; +0.044%] None None None
normalization/normalize_name/normalize_name/good throughput [90994649.100op/s; 91074060.803op/s] or [-0.044%; +0.044%] None None None

Group 8

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
concentrator/add_spans_to_concentrator execution_time 8.297ms 8.312ms ± 0.010ms 8.310ms ± 0.007ms 8.318ms 8.328ms 8.345ms 8.356ms 0.55% 1.273 2.666 0.12% 0.001ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
concentrator/add_spans_to_concentrator execution_time [8.310ms; 8.313ms] or [-0.016%; +0.016%] None None None

Group 9

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
redis/obfuscate_redis_string execution_time 33.693µs 34.212µs ± 0.762µs 33.893µs ± 0.111µs 34.009µs 35.802µs 35.859µs 37.315µs 10.10% 1.757 1.589 2.22% 0.054µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
redis/obfuscate_redis_string execution_time [34.106µs; 34.317µs] or [-0.309%; +0.309%] None None None

Group 10

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
credit_card/is_card_number/ execution_time 3.891µs 3.911µs ± 0.003µs 3.910µs ± 0.001µs 3.912µs 3.915µs 3.918µs 3.919µs 0.22% -1.017 11.033 0.07% 0.000µs 1 200
credit_card/is_card_number/ throughput 255170266.527op/s 255710485.617op/s ± 182480.331op/s 255735099.644op/s ± 91807.974op/s 255811840.937op/s 255924041.024op/s 255971064.240op/s 256984175.624op/s 0.49% 1.043 11.212 0.07% 12903.308op/s 1 200
credit_card/is_card_number/ 3782-8224-6310-005 execution_time 79.760µs 81.838µs ± 0.767µs 81.833µs ± 0.451µs 82.277µs 83.095µs 84.105µs 84.397µs 3.13% 0.235 0.738 0.93% 0.054µs 1 200
credit_card/is_card_number/ 3782-8224-6310-005 throughput 11848822.892op/s 12220298.941op/s ± 114295.723op/s 12220050.331op/s ± 67306.993op/s 12288951.023op/s 12411358.557op/s 12482273.495op/s 12537660.124op/s 2.60% -0.161 0.662 0.93% 8081.928op/s 1 200
credit_card/is_card_number/ 378282246310005 execution_time 74.450µs 74.927µs ± 0.169µs 74.914µs ± 0.094µs 75.009µs 75.203µs 75.420µs 75.682µs 1.02% 0.682 2.157 0.23% 0.012µs 1 200
credit_card/is_card_number/ 378282246310005 throughput 13213158.018op/s 13346386.576op/s ± 30114.753op/s 13348581.268op/s ± 16696.409op/s 13365250.683op/s 13388706.105op/s 13411633.780op/s 13431813.250op/s 0.62% -0.657 2.097 0.23% 2129.435op/s 1 200
credit_card/is_card_number/37828224631 execution_time 3.893µs 3.912µs ± 0.003µs 3.912µs ± 0.002µs 3.914µs 3.916µs 3.919µs 3.919µs 0.19% -1.057 8.392 0.07% 0.000µs 1 200
credit_card/is_card_number/37828224631 throughput 255170037.349op/s 255637681.084op/s ± 183285.104op/s 255649585.905op/s ± 116171.471op/s 255757174.518op/s 255844378.104op/s 255930431.876op/s 256852006.936op/s 0.47% 1.077 8.530 0.07% 12960.214op/s 1 200
credit_card/is_card_number/378282246310005 execution_time 71.486µs 72.048µs ± 0.187µs 72.044µs ± 0.096µs 72.136µs 72.369µs 72.565µs 72.867µs 1.14% 0.437 1.960 0.26% 0.013µs 1 200
credit_card/is_card_number/378282246310005 throughput 13723599.596op/s 13879729.958op/s ± 36041.926op/s 13880421.679op/s ± 18552.820op/s 13900275.921op/s 13938570.676op/s 13967480.747op/s 13988686.876op/s 0.78% -0.407 1.903 0.26% 2548.549op/s 1 200
credit_card/is_card_number/37828224631000521389798 execution_time 52.128µs 52.198µs ± 0.035µs 52.191µs ± 0.022µs 52.218µs 52.264µs 52.292µs 52.295µs 0.20% 0.687 0.035 0.07% 0.002µs 1 200
credit_card/is_card_number/37828224631000521389798 throughput 19122218.464op/s 19157969.648op/s ± 12680.847op/s 19160335.235op/s ± 7918.304op/s 19167147.031op/s 19175178.021op/s 19178375.197op/s 19183622.941op/s 0.12% -0.684 0.030 0.07% 896.671op/s 1 200
credit_card/is_card_number/x371413321323331 execution_time 5.692µs 5.875µs ± 0.072µs 5.878µs ± 0.051µs 5.929µs 5.995µs 6.035µs 6.038µs 2.73% -0.170 -0.177 1.23% 0.005µs 1 200
credit_card/is_card_number/x371413321323331 throughput 165615056.574op/s 170234618.113op/s ± 2096612.490op/s 170134314.605op/s ± 1490996.654op/s 171626409.682op/s 173975381.956op/s 175586855.922op/s 175698933.565op/s 3.27% 0.237 -0.133 1.23% 148252.891op/s 1 200
credit_card/is_card_number_no_luhn/ execution_time 3.890µs 3.911µs ± 0.003µs 3.911µs ± 0.002µs 3.913µs 3.917µs 3.921µs 3.922µs 0.27% -0.867 11.447 0.08% 0.000µs 1 200
credit_card/is_card_number_no_luhn/ throughput 255003598.262op/s 255662229.554op/s ± 202997.811op/s 255680022.181op/s ± 110137.301op/s 255782811.396op/s 255899530.843op/s 255936449.515op/s 257074317.391op/s 0.55% 0.897 11.640 0.08% 14354.113op/s 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time 64.106µs 64.291µs ± 0.095µs 64.273µs ± 0.051µs 64.333µs 64.442µs 64.659µs 64.807µs 0.83% 1.878 6.031 0.15% 0.007µs 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput 15430422.740op/s 15554197.066op/s ± 22833.825op/s 15558553.573op/s ± 12362.292op/s 15569940.673op/s 15578843.697op/s 15584316.802op/s 15599274.634op/s 0.26% -1.858 5.915 0.15% 1614.595op/s 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time 57.371µs 57.551µs ± 0.111µs 57.527µs ± 0.069µs 57.622µs 57.759µs 57.879µs 57.990µs 0.80% 0.992 1.004 0.19% 0.008µs 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 throughput 17244396.909op/s 17375840.419op/s ± 33525.483op/s 17383019.400op/s ± 20810.313op/s 17399670.723op/s 17416011.759op/s 17428959.176op/s 17430522.588op/s 0.27% -0.981 0.967 0.19% 2370.610op/s 1 200
credit_card/is_card_number_no_luhn/37828224631 execution_time 3.892µs 3.911µs ± 0.003µs 3.911µs ± 0.002µs 3.912µs 3.916µs 3.919µs 3.920µs 0.24% -0.701 8.769 0.07% 0.000µs 1 200
credit_card/is_card_number_no_luhn/37828224631 throughput 255083997.654op/s 255683006.314op/s ± 191537.273op/s 255701917.765op/s ± 101529.150op/s 255804406.570op/s 255913306.300op/s 255965147.391op/s 256942264.460op/s 0.49% 0.724 8.911 0.07% 13543.730op/s 1 200
credit_card/is_card_number_no_luhn/378282246310005 execution_time 54.571µs 54.776µs ± 0.140µs 54.742µs ± 0.073µs 54.836µs 55.047µs 55.202µs 55.288µs 1.00% 1.243 1.481 0.26% 0.010µs 1 200
credit_card/is_card_number_no_luhn/378282246310005 throughput 18086984.161op/s 18256398.157op/s ± 46663.802op/s 18267533.114op/s ± 24257.236op/s 18289719.808op/s 18311207.837op/s 18322548.132op/s 18324791.611op/s 0.31% -1.229 1.431 0.25% 3299.629op/s 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time 52.122µs 52.188µs ± 0.034µs 52.185µs ± 0.020µs 52.205µs 52.254µs 52.276µs 52.366µs 0.35% 1.183 3.376 0.06% 0.002µs 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput 19096373.529op/s 19161413.043op/s ± 12402.218op/s 19162775.351op/s ± 7307.981op/s 19169620.465op/s 19177295.233op/s 19184345.997op/s 19185837.015op/s 0.12% -1.175 3.338 0.06% 876.969op/s 1 200
credit_card/is_card_number_no_luhn/x371413321323331 execution_time 5.698µs 5.883µs ± 0.070µs 5.890µs ± 0.043µs 5.930µs 5.988µs 6.025µs 6.029µs 2.35% -0.371 -0.137 1.18% 0.005µs 1 200
credit_card/is_card_number_no_luhn/x371413321323331 throughput 165870245.561op/s 170017522.662op/s ± 2021806.331op/s 169767461.281op/s ± 1230120.930op/s 171325582.006op/s 173564957.948op/s 175420057.732op/s 175512279.046op/s 3.38% 0.432 -0.072 1.19% 142963.297op/s 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
credit_card/is_card_number/ execution_time [3.910µs; 3.911µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/ throughput [255685195.598op/s; 255735775.636op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 execution_time [81.732µs; 81.944µs] or [-0.130%; +0.130%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 throughput [12204458.653op/s; 12236139.229op/s] or [-0.130%; +0.130%] None None None
credit_card/is_card_number/ 378282246310005 execution_time [74.904µs; 74.950µs] or [-0.031%; +0.031%] None None None
credit_card/is_card_number/ 378282246310005 throughput [13342212.961op/s; 13350560.191op/s] or [-0.031%; +0.031%] None None None
credit_card/is_card_number/37828224631 execution_time [3.911µs; 3.912µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/37828224631 throughput [255612279.531op/s; 255663082.637op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/378282246310005 execution_time [72.022µs; 72.074µs] or [-0.036%; +0.036%] None None None
credit_card/is_card_number/378282246310005 throughput [13874734.894op/s; 13884725.022op/s] or [-0.036%; +0.036%] None None None
credit_card/is_card_number/37828224631000521389798 execution_time [52.193µs; 52.202µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/37828224631000521389798 throughput [19156212.205op/s; 19159727.092op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/x371413321323331 execution_time [5.865µs; 5.885µs] or [-0.170%; +0.170%] None None None
credit_card/is_card_number/x371413321323331 throughput [169944047.786op/s; 170525188.440op/s] or [-0.171%; +0.171%] None None None
credit_card/is_card_number_no_luhn/ execution_time [3.911µs; 3.912µs] or [-0.011%; +0.011%] None None None
credit_card/is_card_number_no_luhn/ throughput [255634096.010op/s; 255690363.099op/s] or [-0.011%; +0.011%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time [64.278µs; 64.305µs] or [-0.020%; +0.020%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput [15551032.517op/s; 15557361.615op/s] or [-0.020%; +0.020%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time [57.536µs; 57.567µs] or [-0.027%; +0.027%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 throughput [17371194.110op/s; 17380486.729op/s] or [-0.027%; +0.027%] None None None
credit_card/is_card_number_no_luhn/37828224631 execution_time [3.911µs; 3.912µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/37828224631 throughput [255656461.090op/s; 255709551.538op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/378282246310005 execution_time [54.756µs; 54.795µs] or [-0.036%; +0.036%] None None None
credit_card/is_card_number_no_luhn/378282246310005 throughput [18249931.003op/s; 18262865.311op/s] or [-0.035%; +0.035%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time [52.184µs; 52.193µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput [19159694.215op/s; 19163131.871op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 execution_time [5.873µs; 5.892µs] or [-0.164%; +0.164%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 throughput [169737319.749op/s; 170297725.574op/s] or [-0.165%; +0.165%] None None None

Group 11

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
benching deserializing traces from msgpack to their internal representation execution_time 73.271ms 73.795ms ± 0.257ms 73.771ms ± 0.178ms 73.979ms 74.200ms 74.497ms 74.735ms 1.31% 0.518 0.243 0.35% 0.018ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
benching deserializing traces from msgpack to their internal representation execution_time [73.759ms; 73.830ms] or [-0.048%; +0.048%] None None None

Group 12

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
two way interface execution_time 17.765µs 26.215µs ± 10.127µs 18.175µs ± 0.295µs 35.589µs 44.433µs 46.208µs 68.861µs 278.89% 0.849 0.048 38.53% 0.716µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
two way interface execution_time [24.811µs; 27.618µs] or [-5.354%; +5.354%] None None None

Group 13

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 6c28f32 1752684030 yiming.luo/send-data-get-mut-target
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... execution_time 535.669µs 536.574µs ± 0.798µs 536.442µs ± 0.225µs 536.711µs 537.451µs 538.417µs 545.396µs 1.67% 7.315 74.555 0.15% 0.056µs 1 200
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput 1833528.946op/s 1863678.334op/s ± 2740.461op/s 1864133.404op/s ± 781.768op/s 1864820.531op/s 1865731.646op/s 1866510.064op/s 1866823.451op/s 0.14% -7.214 72.966 0.15% 193.780op/s 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time 379.452µs 380.281µs ± 0.372µs 380.286µs ± 0.262µs 380.522µs 380.908µs 381.258µs 381.459µs 0.31% 0.285 -0.010 0.10% 0.026µs 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput 2621516.702op/s 2629639.220op/s ± 2570.761op/s 2629601.481op/s ± 1809.143op/s 2631497.654op/s 2633681.388op/s 2634956.521op/s 2635378.838op/s 0.22% -0.279 -0.017 0.10% 181.780op/s 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time 194.601µs 195.098µs ± 0.260µs 195.106µs ± 0.200µs 195.282µs 195.481µs 195.674µs 195.996µs 0.46% 0.287 -0.205 0.13% 0.018µs 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput 5102154.532op/s 5125648.352op/s ± 6828.994op/s 5125421.077op/s ± 5261.458op/s 5130787.832op/s 5135899.136op/s 5138252.583op/s 5138727.383op/s 0.26% -0.281 -0.219 0.13% 482.883op/s 1 200
normalization/normalize_service/normalize_service/[empty string] execution_time 36.770µs 36.968µs ± 0.099µs 36.982µs ± 0.077µs 37.046µs 37.108µs 37.162µs 37.173µs 0.52% -0.178 -1.106 0.27% 0.007µs 1 200
normalization/normalize_service/normalize_service/[empty string] throughput 26901159.376op/s 27050913.732op/s ± 72466.051op/s 27039905.453op/s ± 56225.188op/s 27113696.208op/s 27167792.117op/s 27176745.830op/s 27196127.789op/s 0.58% 0.185 -1.106 0.27% 5124.124op/s 1 200
normalization/normalize_service/normalize_service/test_ASCII execution_time 45.867µs 46.046µs ± 0.133µs 46.042µs ± 0.049µs 46.088µs 46.158µs 46.235µs 47.615µs 3.42% 8.143 93.928 0.29% 0.009µs 1 200
normalization/normalize_service/normalize_service/test_ASCII throughput 21001937.079op/s 21717668.234op/s ± 61483.429op/s 21719302.391op/s ± 22890.748op/s 21745148.432op/s 21779469.280op/s 21792488.665op/s 21802346.708op/s 0.38% -7.888 90.025 0.28% 4347.535op/s 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... execution_time [536.464µs; 536.685µs] or [-0.021%; +0.021%] None None None
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput [1863298.533op/s; 1864058.136op/s] or [-0.020%; +0.020%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time [380.229µs; 380.332µs] or [-0.014%; +0.014%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput [2629282.937op/s; 2629995.503op/s] or [-0.014%; +0.014%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time [195.062µs; 195.134µs] or [-0.018%; +0.018%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput [5124701.920op/s; 5126594.785op/s] or [-0.018%; +0.018%] None None None
normalization/normalize_service/normalize_service/[empty string] execution_time [36.954µs; 36.981µs] or [-0.037%; +0.037%] None None None
normalization/normalize_service/normalize_service/[empty string] throughput [27040870.634op/s; 27060956.829op/s] or [-0.037%; +0.037%] None None None
normalization/normalize_service/normalize_service/test_ASCII execution_time [46.027µs; 46.064µs] or [-0.040%; +0.040%] None None None
normalization/normalize_service/normalize_service/test_ASCII throughput [21709147.222op/s; 21726189.246op/s] or [-0.039%; +0.039%] None None None

Baseline

Omitted due to size.

@ekump
Copy link
Contributor

ekump commented Jul 14, 2025

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 70.24 MB 70.24 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so.debug 22.10 MB 22.10 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 9.24 MB 9.24 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 9.09 MB 9.09 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so.debug 26.16 MB 26.16 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 82.46 MB 82.46 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 18.37 MB 18.37 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 65.03 KB 65.03 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 124.77 MB 124.78 MB +0% (+8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 644.67 MB 644.68 MB +0% (+6.29 KB) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 5.87 MB 5.87 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 65.03 KB 65.03 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 17.33 MB 17.33 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 32.14 MB 32.14 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 15.66 MB 15.66 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 66.03 KB 66.03 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 127.16 MB 127.16 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 634.39 MB 634.40 MB +0% (+6.14 KB) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 4.48 MB 4.48 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 66.03 KB 66.03 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 18.47 MB 18.47 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 30.19 MB 30.19 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 62.98 MB 62.98 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 9.84 MB 9.84 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so.debug 20.95 MB 20.95 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 77.43 MB 77.43 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 9.74 MB 9.74 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so.debug 24.08 MB 24.08 MB 0% (0 B) 👌

@lym953 lym953 marked this pull request as draft July 14, 2025 21:42
@lym953 lym953 force-pushed the yiming.luo/send-data-get-mut-target branch 2 times, most recently from e5112d1 to 0b1b61e Compare July 15, 2025 13:55
@lym953 lym953 changed the title Add SendData.set_api_key() Add functions to SendDataBuilder Jul 15, 2025
@lym953 lym953 marked this pull request as ready for review July 15, 2025 14:10
@lym953 lym953 requested a review from ekump July 15, 2025 14:10
/// # Returns
///
/// The size of the data.
pub fn len(&self) -> usize {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think adding getters to builders is generally a good idea. The value of the builder pattern in Rust is to allow flexible setting of parameters while deferring construction until build() is called. This means the properties on the builder can represent an invalid state for the thing being built. It also means the values may not be set at all.

I'm not recommending it be changed as part of this PR as it already exists...but I would argue all properties should be Option on a builder. Size shouldn't just be usize. Is the size actually 0? Or have we just not set it yet on the builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I will pass the size alongside SendDataBuilder in our codebase instead of calling the getter.

@lym953 lym953 force-pushed the yiming.luo/send-data-get-mut-target branch from 391a01a to 6c28f32 Compare July 16, 2025 16:40
@lym953
Copy link
Contributor Author

lym953 commented Jul 16, 2025

/merge

@dd-devflow-routing-codex
Copy link

dd-devflow-routing-codex bot commented Jul 16, 2025

View all feedbacks in Devflow UI.

2025-07-16 19:07:40 UTC ℹ️ Start processing command /merge


2025-07-16 19:07:54 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 40m (p90).


2025-07-16 19:38:45 UTC ℹ️ MergeQueue: This merge request was merged

@dd-mergequeue dd-mergequeue bot merged commit 8a49c7d into main Jul 16, 2025
55 of 59 checks passed
@dd-mergequeue dd-mergequeue bot deleted the yiming.luo/send-data-get-mut-target branch July 16, 2025 19:38
lym953 added a commit to DataDog/datadog-lambda-extension that referenced this pull request Jul 16, 2025
…745)

# Background
Right now `SendData` is passed around across channels.

# This PR

Instead of passing `SendData`, pass `SendDataBuilderInfo`, which bundles
`SendDataBuilder` and payload size. Just before flush, call
`SendDataBuilder.build()` to build `SendData`.

# Motivation
DataDog/libdatadog#1140 (comment)
It is suggested that the function `set_api_key()` shouldn't be added on
`SendData`, but should be added on `SendDataBuilder`. Because need to
call `set_api_key()` just before flush, we need to make sure the object
is `SendDataBuilder` instead of `SendData` 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 with `SendDataBuilder`.

# Next steps
Update #717
#732 so that
`get_api_key()` is called just before flush.

# Dependency
DataDog/libdatadog#1140
lym953 added a commit to DataDog/datadog-lambda-extension that referenced this pull request Jul 17, 2025
# Context
The previous PR
#717 defers API
key resolution from extension init stage to flush time. However, that PR
doesn't well handle the failure case.
- Before that PR, if resolution fails in init stage, the extension will
run an idle loop.
- After that PR, the extension will crash at flush time, which will kill
the runtime as well, which is not desired.

# What does this PR do?
1. For traces, defer key resolution from
`TraceProcessor.process_traces()` to `TraceFlusher.flush()`.
- (This should ideally be in the previous PR, but since that is already
approved, let me add this change in this new PR.)
2. If resolution fails at flush time, then make flush a no-op, so the
extension can keep running and consume events without crashing.

# Dependencies
1. DataDog/serverless-components#25
2. DataDog/libdatadog#1140

# Manual Test

## Steps
1. Create a layer in sandbox
2. Apply the layer to a Lambda function
3. Set the env var `DD_API_KEY_SECRET_ARN` to an invalid value
5. Run the Lambda
6. Then set `DD_API_KEY_SECRET_ARN` to a valid value
7. Run the Lambda

## Result
1. The function was successful
<img width="319" alt="image"
src="https://github.com/user-attachments/assets/f8a5cb36-f678-4643-ba1c-85f41256ffa1"
/>

2. The extension printed some error logs
<img width="737" height="33" alt="image"
src="https://github.com/user-attachments/assets/22553d24-e1f5-4ee5-9a91-0d18e3e2f297"
/>

<img width="603" height="186" alt="image"
src="https://github.com/user-attachments/assets/e797f991-ecba-45f0-8f49-7b7b59dd9e7b"
/>

3. With valid secret ARN, the Lambda runs successfully and reports to
Datadog
<img width="678" height="150" alt="image"
src="https://github.com/user-attachments/assets/073089f8-1e9a-4728-b8d1-1db7aa85d031"
/>

<img width="533" height="96" alt="image"
src="https://github.com/user-attachments/assets/d5f2b81c-5e02-42bc-b3ef-85e611228fc6"
/>


# Automated Test

I didn't add any automated test because from what I see in the codebase,
existing tests are usually unit tests for short functions and not for
long functions that this PR touches. Please let me know if you think I
should add automated tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants