Skip to content

Conversation

@danielsn
Copy link
Contributor

What does this PR do?

Takes sample types by enum rather than as tuples of strings.

Motivation

  • A way to avoid random inconsistencies between names, units, redundancy, etc
  • First step towards an OTEL style API

Additional Notes

Added experimental enum variants to allow users to experiment without needing to update libdatadog.

How to test the change?

Describe here in detail how the change can be validated.

@pr-commenter
Copy link

pr-commenter bot commented Jan 14, 2026

Benchmarks

Comparison

Benchmark execution time: 2026-01-22 23:08:24

Comparing candidate commit 3c1a633 in PR branch dsn/sample-type-enum with baseline commit fa16176 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 57 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 3c1a633 1769122340 dsn/sample-type-enum
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.601µs 34.172µs ± 0.919µs 33.740µs ± 0.064µs 33.890µs 36.088µs 36.129µs 37.965µs 12.52% 1.778 1.654 2.68% 0.065µ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.045µs; 34.300µs] or [-0.373%; +0.373%] None None None

Group 2

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
receiver_entry_point/report/2597 execution_time 12.645ms 13.006ms ± 0.080ms 13.014ms ± 0.036ms 13.048ms 13.106ms 13.150ms 13.242ms 1.75% -1.430 5.229 0.61% 0.006ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
receiver_entry_point/report/2597 execution_time [12.995ms; 13.017ms] or [-0.085%; +0.085%] None None None

Group 3

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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 241.097ns 254.852ns ± 14.884ns 248.624ns ± 4.938ns 267.036ns 288.414ns 291.479ns 293.128ns 17.90% 1.174 -0.003 5.83% 1.052ns 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 [252.790ns; 256.915ns] or [-0.809%; +0.809%] None None None

Group 4

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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.201µs 536.640µs ± 1.192µs 536.249µs ± 0.420µs 536.841µs 538.911µs 540.869µs 541.628µs 1.00% 1.856 3.452 0.22% 0.084µs 1 200
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput 1846285.843op/s 1863455.029op/s ± 4122.240op/s 1864805.445op/s ± 1459.326op/s 1866050.709op/s 1867325.717op/s 1867947.769op/s 1868455.255op/s 0.20% -1.843 3.387 0.22% 291.486op/s 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time 380.939µs 382.322µs ± 0.368µs 382.321µs ± 0.221µs 382.555µs 382.838µs 383.133µs 383.305µs 0.26% -0.829 2.469 0.10% 0.026µs 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput 2608890.259op/s 2615595.393op/s ± 2521.618op/s 2615605.350op/s ± 1515.502op/s 2617102.165op/s 2618774.533op/s 2624410.997op/s 2625093.105op/s 0.36% 0.840 2.496 0.10% 178.305op/s 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time 189.690µs 190.192µs ± 0.208µs 190.180µs ± 0.138µs 190.334µs 190.544µs 190.666µs 190.899µs 0.38% 0.168 0.180 0.11% 0.015µs 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput 5238381.974op/s 5257847.029op/s ± 5752.172op/s 5258189.934op/s ± 3811.319op/s 5261440.826op/s 5267722.829op/s 5270187.276op/s 5271750.635op/s 0.26% -0.161 0.174 0.11% 406.740op/s 1 200
normalization/normalize_service/normalize_service/[empty string] execution_time 36.495µs 36.606µs ± 0.049µs 36.603µs ± 0.034µs 36.639µs 36.686µs 36.729µs 36.759µs 0.43% 0.285 -0.076 0.13% 0.003µs 1 200
normalization/normalize_service/normalize_service/[empty string] throughput 27204147.207op/s 27317689.169op/s ± 36459.462op/s 27320167.240op/s ± 25683.548op/s 27345326.674op/s 27372255.875op/s 27391601.041op/s 27401179.197op/s 0.30% -0.278 -0.086 0.13% 2578.073op/s 1 200
normalization/normalize_service/normalize_service/test_ASCII execution_time 45.929µs 46.042µs ± 0.062µs 46.035µs ± 0.031µs 46.070µs 46.130µs 46.177µs 46.563µs 1.15% 3.261 23.738 0.13% 0.004µs 1 200
normalization/normalize_service/normalize_service/test_ASCII throughput 21476202.578op/s 21719256.286op/s ± 29246.713op/s 21722421.488op/s ± 14551.784op/s 21734997.378op/s 21756523.578op/s 21768012.960op/s 21772883.664op/s 0.23% -3.201 23.093 0.13% 2068.055op/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.475µs; 536.805µs] or [-0.031%; +0.031%] None None None
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput [1862883.726op/s; 1864026.331op/s] or [-0.031%; +0.031%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time [382.271µs; 382.374µs] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput [2615245.921op/s; 2615944.865op/s] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time [190.163µs; 190.221µs] or [-0.015%; +0.015%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput [5257049.834op/s; 5258644.225op/s] or [-0.015%; +0.015%] None None None
normalization/normalize_service/normalize_service/[empty string] execution_time [36.600µs; 36.613µs] or [-0.019%; +0.019%] None None None
normalization/normalize_service/normalize_service/[empty string] throughput [27312636.238op/s; 27322742.100op/s] or [-0.018%; +0.018%] None None None
normalization/normalize_service/normalize_service/test_ASCII execution_time [46.034µs; 46.051µs] or [-0.019%; +0.019%] None None None
normalization/normalize_service/normalize_service/test_ASCII throughput [21715202.973op/s; 21723309.599op/s] or [-0.019%; +0.019%] None None None

Group 5

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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.390µs 24.962µs ± 9.607µs 17.671µs ± 0.195µs 33.778µs 42.474µs 44.704µs 70.021µs 296.25% 1.028 0.889 38.39% 0.679µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
two way interface execution_time [23.631µs; 26.294µs] or [-5.334%; +5.334%] None None None

Group 6

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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 5.003µs 5.087µs ± 0.037µs 5.087µs ± 0.024µs 5.105µs 5.161µs 5.178µs 5.193µs 2.08% 0.468 -0.111 0.72% 0.003µ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.082µs; 5.092µs] or [-0.100%; +0.100%] None None None

Group 7

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
profile_add_sample2_frames_x1000 execution_time 533.358µs 533.865µs ± 0.322µs 533.800µs ± 0.161µs 533.976µs 534.356µs 534.871µs 536.043µs 0.42% 2.252 10.338 0.06% 0.023µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
profile_add_sample2_frames_x1000 execution_time [533.820µs; 533.910µs] or [-0.008%; +0.008%] None None None

Group 8

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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.402µs 2.427µs ± 0.017µs 2.423µs ± 0.011µs 2.439µs 2.458µs 2.465µs 2.476µs 2.20% 0.618 -0.532 0.68% 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.425µs; 2.430µs] or [-0.095%; +0.095%] None None None

Group 9

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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 48.464ms 48.911ms ± 0.889ms 48.789ms ± 0.053ms 48.843ms 48.933ms 51.516ms 57.910ms 18.70% 8.195 72.301 1.81% 0.063ms 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 [48.787ms; 49.034ms] or [-0.252%; +0.252%] None None None

Group 10

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
single_flag_killswitch/rules-based execution_time 188.087ns 190.660ns ± 2.139ns 190.285ns ± 1.399ns 191.715ns 194.657ns 197.583ns 198.302ns 4.21% 1.136 1.217 1.12% 0.151ns 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
single_flag_killswitch/rules-based execution_time [190.364ns; 190.957ns] or [-0.156%; +0.156%] None None None

Group 11

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
sdk_test_data/rules-based execution_time 143.741µs 145.858µs ± 1.813µs 145.509µs ± 0.577µs 146.194µs 147.805µs 152.415µs 162.612µs 11.75% 5.444 41.320 1.24% 0.128µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
sdk_test_data/rules-based execution_time [145.607µs; 146.109µs] or [-0.172%; +0.172%] None None None

Group 12

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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.892µs 3.912µs ± 0.003µs 3.912µs ± 0.002µs 3.913µs 3.916µs 3.918µs 3.918µs 0.17% -1.608 13.115 0.07% 0.000µs 1 200
credit_card/is_card_number/ throughput 255207602.452op/s 255650236.324op/s ± 172801.836op/s 255653100.448op/s ± 104440.829op/s 255758031.498op/s 255876533.067op/s 255934706.477op/s 256918229.167op/s 0.49% 1.634 13.322 0.07% 12218.935op/s 1 200
credit_card/is_card_number/ 3782-8224-6310-005 execution_time 77.079µs 77.644µs ± 0.344µs 77.627µs ± 0.235µs 77.872µs 78.241µs 78.584µs 78.662µs 1.33% 0.606 0.163 0.44% 0.024µs 1 200
credit_card/is_card_number/ 3782-8224-6310-005 throughput 12712626.062op/s 12879627.554op/s ± 56957.775op/s 12882054.654op/s ± 39010.413op/s 12920427.523op/s 12965362.549op/s 12972037.982op/s 12973767.545op/s 0.71% -0.583 0.121 0.44% 4027.523op/s 1 200
credit_card/is_card_number/ 378282246310005 execution_time 70.653µs 71.094µs ± 0.328µs 71.003µs ± 0.220µs 71.256µs 71.670µs 71.975µs 72.513µs 2.13% 1.011 1.319 0.46% 0.023µs 1 200
credit_card/is_card_number/ 378282246310005 throughput 13790584.786op/s 14066117.083op/s ± 64508.339op/s 14084001.989op/s ± 43750.162op/s 14109115.907op/s 14145404.414op/s 14150456.496op/s 14153690.610op/s 0.49% -0.979 1.198 0.46% 4561.428op/s 1 200
credit_card/is_card_number/37828224631 execution_time 3.894µs 3.912µs ± 0.002µs 3.912µs ± 0.001µs 3.914µs 3.916µs 3.918µs 3.919µs 0.18% -1.473 14.766 0.06% 0.000µs 1 200
credit_card/is_card_number/37828224631 throughput 255170140.382op/s 255607408.525op/s ± 158867.254op/s 255630036.537op/s ± 78946.632op/s 255695272.064op/s 255790169.760op/s 255837971.271op/s 256799020.306op/s 0.46% 1.501 14.983 0.06% 11233.611op/s 1 200
credit_card/is_card_number/378282246310005 execution_time 67.408µs 67.861µs ± 0.273µs 67.804µs ± 0.191µs 68.020µs 68.333µs 68.617µs 68.841µs 1.53% 0.706 0.327 0.40% 0.019µs 1 200
credit_card/is_card_number/378282246310005 throughput 14526180.053op/s 14736172.498op/s ± 59129.511op/s 14748388.025op/s ± 41489.312op/s 14773123.369op/s 14821208.705op/s 14825405.007op/s 14835009.138op/s 0.59% -0.684 0.273 0.40% 4181.088op/s 1 200
credit_card/is_card_number/37828224631000521389798 execution_time 44.590µs 45.110µs ± 0.208µs 45.137µs ± 0.154µs 45.276µs 45.380µs 45.500µs 45.535µs 0.88% -0.460 -0.460 0.46% 0.015µs 1 200
credit_card/is_card_number/37828224631000521389798 throughput 21961002.799op/s 22168274.166op/s ± 102331.316op/s 22154925.816op/s ± 75135.919op/s 22235300.903op/s 22363344.331op/s 22401899.248op/s 22426591.553op/s 1.23% 0.479 -0.443 0.46% 7235.917op/s 1 200
credit_card/is_card_number/x371413321323331 execution_time 6.029µs 6.036µs ± 0.007µs 6.035µs ± 0.002µs 6.037µs 6.044µs 6.072µs 6.081µs 0.76% 3.767 19.185 0.11% 0.000µs 1 200
credit_card/is_card_number/x371413321323331 throughput 164448448.637op/s 165666555.325op/s ± 181582.966op/s 165700894.785op/s ± 65916.261op/s 165764038.793op/s 165832432.956op/s 165864541.440op/s 165875678.932op/s 0.11% -3.744 18.988 0.11% 12839.855op/s 1 200
credit_card/is_card_number_no_luhn/ execution_time 3.894µs 3.912µs ± 0.003µs 3.912µs ± 0.001µs 3.914µs 3.917µs 3.918µs 3.922µs 0.23% -1.271 11.645 0.07% 0.000µs 1 200
credit_card/is_card_number_no_luhn/ throughput 255004449.863op/s 255592831.843op/s ± 173068.225op/s 255597773.671op/s ± 95388.967op/s 255695339.953op/s 255811517.194op/s 255882012.176op/s 256818134.795op/s 0.48% 1.295 11.821 0.07% 12237.772op/s 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time 65.469µs 65.722µs ± 0.088µs 65.734µs ± 0.055µs 65.785µs 65.848µs 65.875µs 65.904µs 0.26% -0.540 -0.202 0.13% 0.006µs 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput 15173638.491op/s 15215617.090op/s ± 20499.651op/s 15212718.549op/s ± 12829.169op/s 15227214.676op/s 15254397.589op/s 15265441.287op/s 15274384.857op/s 0.41% 0.546 -0.195 0.13% 1449.544op/s 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time 52.956µs 53.031µs ± 0.034µs 53.029µs ± 0.025µs 53.055µs 53.090µs 53.106µs 53.121µs 0.17% 0.236 -0.388 0.06% 0.002µs 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 throughput 18825018.071op/s 18856817.399op/s ± 11950.056op/s 18857654.195op/s ± 8899.247op/s 18865604.232op/s 18874081.075op/s 18881378.467op/s 18883454.317op/s 0.14% -0.233 -0.390 0.06% 844.997op/s 1 200
credit_card/is_card_number_no_luhn/37828224631 execution_time 3.893µs 3.913µs ± 0.003µs 3.913µs ± 0.002µs 3.915µs 3.917µs 3.918µs 3.920µs 0.19% -1.614 11.005 0.07% 0.000µs 1 200
credit_card/is_card_number_no_luhn/37828224631 throughput 255070779.147op/s 255559726.053op/s ± 182221.975op/s 255556223.222op/s ± 115390.398op/s 255666760.990op/s 255806547.182op/s 255899831.450op/s 256850476.545op/s 0.51% 1.636 11.187 0.07% 12885.039op/s 1 200
credit_card/is_card_number_no_luhn/378282246310005 execution_time 49.733µs 49.809µs ± 0.030µs 49.806µs ± 0.021µs 49.828µs 49.860µs 49.880µs 49.892µs 0.17% 0.250 -0.249 0.06% 0.002µs 1 200
credit_card/is_card_number_no_luhn/378282246310005 throughput 20043281.522op/s 20076768.378op/s ± 12001.311op/s 20077762.874op/s ± 8435.313op/s 20085856.544op/s 20094867.269op/s 20100556.484op/s 20107425.672op/s 0.15% -0.247 -0.251 0.06% 848.621op/s 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time 44.642µs 45.119µs ± 0.177µs 45.130µs ± 0.132µs 45.260µs 45.377µs 45.407µs 45.417µs 0.64% -0.369 -0.574 0.39% 0.013µs 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput 22017999.218op/s 22164011.737op/s ± 87062.981op/s 22158281.504op/s ± 65044.116op/s 22224018.053op/s 22312853.844op/s 22370022.168op/s 22400608.651op/s 1.09% 0.384 -0.554 0.39% 6156.282op/s 1 200
credit_card/is_card_number_no_luhn/x371413321323331 execution_time 6.027µs 6.036µs ± 0.009µs 6.035µs ± 0.002µs 6.037µs 6.042µs 6.101µs 6.103µs 1.13% 5.801 38.670 0.15% 0.001µs 1 200
credit_card/is_card_number_no_luhn/x371413321323331 throughput 163853761.359op/s 165663575.280op/s ± 247209.743op/s 165698906.398op/s ± 62128.596op/s 165758396.693op/s 165838064.335op/s 165893616.430op/s 165923216.503op/s 0.14% -5.770 38.358 0.15% 17480.369op/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.911µs; 3.912µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/ throughput [255626287.651op/s; 255674184.996op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 execution_time [77.596µs; 77.691µs] or [-0.061%; +0.061%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 throughput [12871733.754op/s; 12887521.354op/s] or [-0.061%; +0.061%] None None None
credit_card/is_card_number/ 378282246310005 execution_time [71.049µs; 71.140µs] or [-0.064%; +0.064%] None None None
credit_card/is_card_number/ 378282246310005 throughput [14057176.848op/s; 14075057.319op/s] or [-0.064%; +0.064%] None None None
credit_card/is_card_number/37828224631 execution_time [3.912µs; 3.913µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/37828224631 throughput [255585391.052op/s; 255629425.999op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/378282246310005 execution_time [67.823µs; 67.899µs] or [-0.056%; +0.056%] None None None
credit_card/is_card_number/378282246310005 throughput [14727977.716op/s; 14744367.279op/s] or [-0.056%; +0.056%] None None None
credit_card/is_card_number/37828224631000521389798 execution_time [45.082µs; 45.139µs] or [-0.064%; +0.064%] None None None
credit_card/is_card_number/37828224631000521389798 throughput [22154092.030op/s; 22182456.302op/s] or [-0.064%; +0.064%] None None None
credit_card/is_card_number/x371413321323331 execution_time [6.035µs; 6.037µs] or [-0.015%; +0.015%] None None None
credit_card/is_card_number/x371413321323331 throughput [165641389.673op/s; 165691720.978op/s] or [-0.015%; +0.015%] None None None
credit_card/is_card_number_no_luhn/ execution_time [3.912µs; 3.913µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/ throughput [255568846.251op/s; 255616817.434op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time [65.710µs; 65.734µs] or [-0.019%; +0.019%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput [15212776.036op/s; 15218458.145op/s] or [-0.019%; +0.019%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time [53.027µs; 53.036µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 throughput [18855161.236op/s; 18858473.562op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/37828224631 execution_time [3.913µs; 3.913µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/37828224631 throughput [255534471.840op/s; 255584980.266op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/378282246310005 execution_time [49.805µs; 49.813µs] or [-0.008%; +0.008%] None None None
credit_card/is_card_number_no_luhn/378282246310005 throughput [20075105.112op/s; 20078431.645op/s] or [-0.008%; +0.008%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time [45.094µs; 45.143µs] or [-0.054%; +0.054%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput [22151945.645op/s; 22176077.829op/s] or [-0.054%; +0.054%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 execution_time [6.035µs; 6.038µs] or [-0.021%; +0.021%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 throughput [165629314.387op/s; 165697836.172op/s] or [-0.021%; +0.021%] None None None

Group 13

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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 88.926µs 89.189µs ± 0.171µs 89.175µs ± 0.063µs 89.239µs 89.321µs 89.676µs 91.102µs 2.16% 7.336 77.188 0.19% 0.012µ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 [89.165µs; 89.213µs] or [-0.027%; +0.027%] None None None

Group 14

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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 10.570ms 10.598ms ± 0.021ms 10.595ms ± 0.010ms 10.606ms 10.625ms 10.667ms 10.772ms 1.67% 3.725 25.551 0.20% 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 [10.595ms; 10.601ms] or [-0.027%; +0.027%] None None None

Group 15

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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 206.055µs 206.609µs ± 0.325µs 206.562µs ± 0.246µs 206.825µs 207.183µs 207.389µs 207.474µs 0.44% 0.514 -0.525 0.16% 0.023µs 1 200
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput 4819886.696op/s 4840067.763op/s ± 7604.845op/s 4841160.225op/s ± 5771.382op/s 4846274.376op/s 4849887.750op/s 4852437.335op/s 4853066.843op/s 0.25% -0.508 -0.533 0.16% 537.744op/s 1 200
normalization/normalize_name/normalize_name/bad-name execution_time 18.578µs 18.676µs ± 0.066µs 18.655µs ± 0.027µs 18.699µs 18.789µs 18.877µs 19.171µs 2.77% 2.847 15.276 0.35% 0.005µs 1 200
normalization/normalize_name/normalize_name/bad-name throughput 52161958.461op/s 53545922.311op/s ± 187882.836op/s 53605272.589op/s ± 77160.336op/s 53666069.025op/s 53732892.337op/s 53789453.814op/s 53826346.172op/s 0.41% -2.753 14.330 0.35% 13285.323op/s 1 200
normalization/normalize_name/normalize_name/good execution_time 10.852µs 10.908µs ± 0.030µs 10.904µs ± 0.015µs 10.922µs 10.962µs 11.004µs 11.053µs 1.37% 1.217 3.452 0.27% 0.002µs 1 200
normalization/normalize_name/normalize_name/good throughput 90475611.643op/s 91680059.257op/s ± 248236.089op/s 91713092.049op/s ± 126092.079op/s 91821217.781op/s 92042681.866op/s 92126303.156op/s 92146060.650op/s 0.47% -1.185 3.312 0.27% 17552.942op/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.564µs; 206.654µs] or [-0.022%; +0.022%] None None None
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput [4839013.804op/s; 4841121.721op/s] or [-0.022%; +0.022%] None None None
normalization/normalize_name/normalize_name/bad-name execution_time [18.667µs; 18.685µs] or [-0.049%; +0.049%] None None None
normalization/normalize_name/normalize_name/bad-name throughput [53519883.556op/s; 53571961.065op/s] or [-0.049%; +0.049%] None None None
normalization/normalize_name/normalize_name/good execution_time [10.903µs; 10.912µs] or [-0.038%; +0.038%] None None None
normalization/normalize_name/normalize_name/good throughput [91645656.122op/s; 91714462.391op/s] or [-0.038%; +0.038%] None None None

Group 16

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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 159.784µs 160.443µs ± 0.322µs 160.411µs ± 0.149µs 160.560µs 160.915µs 161.583µs 162.816µs 1.50% 2.612 15.521 0.20% 0.023µ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 [160.398µs; 160.488µs] or [-0.028%; +0.028%] None None None

Group 17

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
profile_add_sample_frames_x1000 execution_time 3.987ms 3.992ms ± 0.007ms 3.990ms ± 0.001ms 3.992ms 3.995ms 3.997ms 4.082ms 2.29% 11.810 153.932 0.17% 0.000ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
profile_add_sample_frames_x1000 execution_time [3.991ms; 3.992ms] or [-0.024%; +0.024%] None None None

Group 18

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
benching serializing traces from their internal representation to msgpack execution_time 14.620ms 14.700ms ± 0.038ms 14.696ms ± 0.014ms 14.711ms 14.752ms 14.875ms 14.899ms 1.38% 2.460 9.217 0.26% 0.003ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
benching serializing traces from their internal representation to msgpack execution_time [14.695ms; 14.705ms] or [-0.036%; +0.036%] None None None

Group 19

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 3c1a633 1769122340 dsn/sample-type-enum
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.225µs 3.167µs ± 1.431µs 2.998µs ± 0.022µs 3.017µs 3.325µs 13.794µs 15.198µs 406.99% 7.536 57.314 45.07% 0.101µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
write only interface execution_time [2.969µs; 3.366µs] or [-6.262%; +6.262%] None None None

Baseline

Omitted due to size.

@codecov-commenter
Copy link

codecov-commenter commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 75.24752% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.14%. Comparing base (fe7ff46) to head (2e7531b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1450      +/-   ##
==========================================
- Coverage   71.14%   71.14%   -0.01%     
==========================================
  Files         419      419              
  Lines       67165    67227      +62     
==========================================
+ Hits        47786    47826      +40     
- Misses      19379    19401      +22     
Components Coverage Δ
libdd-crashtracker 61.39% <ø> (ø)
libdd-crashtracker-ffi 16.50% <ø> (ø)
libdd-alloc 98.73% <ø> (ø)
libdd-data-pipeline 86.28% <ø> (-0.02%) ⬇️
libdd-data-pipeline-ffi 78.57% <ø> (ø)
libdd-common 80.84% <ø> (ø)
libdd-common-ffi 74.19% <ø> (ø)
libdd-telemetry 59.82% <ø> (ø)
libdd-telemetry-ffi 21.17% <ø> (ø)
libdd-dogstatsd-client 83.75% <ø> (ø)
datadog-ipc 82.70% <ø> (+0.10%) ⬆️
libdd-profiling 80.39% <78.08%> (-0.27%) ⬇️
libdd-profiling-ffi 62.52% <68.42%> (+0.05%) ⬆️
datadog-sidecar 35.02% <ø> (ø)
datdog-sidecar-ffi 10.25% <ø> (ø)
spawn-worker 55.18% <ø> (ø)
libdd-tinybytes 93.43% <ø> (ø)
libdd-trace-normalization 82.33% <ø> (ø)
libdd-trace-obfuscation 94.17% <ø> (ø)
libdd-trace-protobuf 61.18% <ø> (ø)
libdd-trace-utils 89.45% <ø> (ø)
datadog-tracer-flare 63.49% <ø> (ø)
libdd-log 75.57% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@danielsn danielsn force-pushed the dsn/sample-type-enum branch 2 times, most recently from 79ff759 to bd8abfc Compare January 14, 2026 23:19
@dd-octo-sts
Copy link

dd-octo-sts bot commented Jan 15, 2026

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 8.38 MB 8.38 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 91.22 MB 91.18 MB --.04% (-39.89 KB) 💪
aarch64-apple-darwin
Artifact Baseline Commit Change
/aarch64-apple-darwin/lib/libdatadog_profiling.a 62.36 MB 62.31 MB --.08% (-52.99 KB) 💪
/aarch64-apple-darwin/lib/libdatadog_profiling.dylib 9.41 MB 9.41 MB -0% (-976 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.67 MB 10.67 MB +0% (+104 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 105.54 MB 105.49 MB --.04% (-52.64 KB) 💪
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.08 MB 25.07 MB --.06% (-16.50 KB) 💪
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 73.49 KB 73.49 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 165.92 MB 165.74 MB --.10% (-184.00 KB) 💪
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 827.93 MB 827.42 MB --.06% (-522.18 KB) 💪
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 9.54 MB 9.54 MB +0% (+512 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 73.49 KB 73.49 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 22.94 MB 22.92 MB --.06% (-16.00 KB) 💪
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 47.90 MB 47.89 MB --.02% (-10.77 KB) 💪
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.15 MB 21.14 MB --.05% (-12.00 KB) 💪
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 74.62 KB 74.62 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 169.90 MB 169.73 MB --.10% (-176.00 KB) 💪
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 814.90 MB 814.43 MB --.05% (-483.42 KB) 💪
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 7.22 MB 7.21 MB -0% (-512 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 74.62 KB 74.62 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 24.51 MB 24.51 MB --.03% (-8.00 KB) 💪
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 43.62 MB 43.61 MB --.02% (-10.58 KB) 💪
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 79.72 MB 79.68 MB --.05% (-43.02 KB) 💪
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 9.85 MB 9.84 MB --.03% (-4.00 KB) 💪
x86_64-apple-darwin
Artifact Baseline Commit Change
/x86_64-apple-darwin/lib/libdatadog_profiling.a 64.25 MB 64.19 MB --.08% (-56.28 KB) 💪
/x86_64-apple-darwin/lib/libdatadog_profiling.dylib 10.44 MB 10.44 MB --.04% (-4.93 KB) 💪
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 99.56 MB 99.51 MB --.04% (-50.07 KB) 💪
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 11.41 MB 11.41 MB +.02% (+3.00 KB) 🔍

@danielsn danielsn force-pushed the dsn/sample-type-enum branch 2 times, most recently from 60395d1 to 4650827 Compare January 22, 2026 21:52
@danielsn danielsn marked this pull request as ready for review January 22, 2026 21:53
@danielsn danielsn requested review from a team as code owners January 22, 2026 21:53
@danielsn danielsn force-pushed the dsn/sample-type-enum branch from 4650827 to 3c1a633 Compare January 22, 2026 22:52
@danielsn danielsn force-pushed the dsn/sample-type-enum branch from 3c1a633 to 2e7531b Compare January 23, 2026 13:56
Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

Looks very reasonable! Left a few small comments + this would probably benefit from a pass from a real rustacean as I won't catch the more minute details there ;)

Comment on lines +18 to +268
pub enum SampleType {
AllocSamples,
AllocSamplesUnscaled,
AllocSize,
AllocSpace,
CpuTime,
CpuSamples,
/// Legacy: Use `CpuTime` instead for consistency with naming scheme
CpuLegacy,
/// Legacy: Use `CpuSamples` instead for consistency with naming scheme
CpuSampleLegacy,
ExceptionSamples,
/// Legacy: Use `ExceptionSamples` instead for consistency with naming scheme
ExceptionLegacy,
FileIoReadSize,
FileIoReadSizeSamples,
FileIoReadTime,
FileIoReadTimeSamples,
FileIoWriteSize,
FileIoWriteSizeSamples,
FileIoWriteTime,
FileIoWriteTimeSamples,
GpuAllocSamples,
GpuFlops,
GpuFlopsSamples,
GpuSamples,
GpuSpace,
GpuTime,
HeapLiveSamples,
HeapLiveSize,
HeapSpace,
InuseObjects,
InuseSpace,
LockAcquire,
LockAcquireWait,
LockCount,
LockRelease,
LockReleaseHold,
LockTime,
/// Legacy: Use `InuseObjects` instead for consistency with naming scheme
ObjectsLegacy,
RequestTime,
Sample,
SocketReadSize,
SocketReadSizeSamples,
SocketReadTime,
SocketReadTimeSamples,
SocketWriteSize,
SocketWriteSizeSamples,
SocketWriteTime,
SocketWriteTimeSamples,
/// Legacy: Use specific space variants (`InuseSpace`, `HeapSpace`, `AllocSpace`) instead
SpaceLegacy,
Timeline,
WallSamples,
WallTime,
/// Legacy: Use `WallTime` instead for consistency with naming scheme
WallLegacy,

// Experimental sample types for testing and development.
ExperimentalCount,
ExperimentalNanoseconds,
ExperimentalBytes,
}

impl From<&SampleType> for ValueType<'static> {
#[inline(always)]
fn from(sample_type: &SampleType) -> Self {
(*sample_type).into()
}
}

impl From<SampleType> for ValueType<'static> {
#[inline(always)]
fn from(sample_type: SampleType) -> Self {
match sample_type {
SampleType::AllocSamples => ValueType::new("alloc-samples", "count"),
SampleType::AllocSamplesUnscaled => ValueType::new("alloc-samples-unscaled", "count"),
SampleType::AllocSize => ValueType::new("alloc-size", "bytes"),
SampleType::AllocSpace => ValueType::new("alloc-space", "bytes"),
SampleType::CpuTime => ValueType::new("cpu-time", "nanoseconds"),
SampleType::CpuSamples => ValueType::new("cpu-samples", "count"),
SampleType::CpuLegacy => ValueType::new("cpu", "nanoseconds"),
SampleType::CpuSampleLegacy => ValueType::new("cpu-sample", "count"),
SampleType::ExceptionSamples => ValueType::new("exception-samples", "count"),
SampleType::ExceptionLegacy => ValueType::new("exception", "count"),
SampleType::FileIoReadSize => ValueType::new("file-io-read-size", "bytes"),
SampleType::FileIoReadSizeSamples => {
ValueType::new("file-io-read-size-samples", "count")
}
SampleType::FileIoReadTime => ValueType::new("file-io-read-time", "nanoseconds"),
SampleType::FileIoReadTimeSamples => {
ValueType::new("file-io-read-time-samples", "count")
}
SampleType::FileIoWriteSize => ValueType::new("file-io-write-size", "bytes"),
SampleType::FileIoWriteSizeSamples => {
ValueType::new("file-io-write-size-samples", "count")
}
SampleType::FileIoWriteTime => ValueType::new("file-io-write-time", "nanoseconds"),
SampleType::FileIoWriteTimeSamples => {
ValueType::new("file-io-write-time-samples", "count")
}
SampleType::GpuAllocSamples => ValueType::new("gpu-alloc-samples", "count"),
SampleType::GpuFlops => ValueType::new("gpu-flops", "count"),
SampleType::GpuFlopsSamples => ValueType::new("gpu-flops-samples", "count"),
SampleType::GpuSamples => ValueType::new("gpu-samples", "count"),
SampleType::GpuSpace => ValueType::new("gpu-space", "bytes"),
SampleType::GpuTime => ValueType::new("gpu-time", "nanoseconds"),
SampleType::HeapLiveSamples => ValueType::new("heap-live-samples", "count"),
SampleType::HeapLiveSize => ValueType::new("heap-live-size", "bytes"),
SampleType::HeapSpace => ValueType::new("heap-space", "bytes"),
SampleType::InuseObjects => ValueType::new("inuse-objects", "count"),
SampleType::InuseSpace => ValueType::new("inuse-space", "bytes"),
SampleType::LockAcquire => ValueType::new("lock-acquire", "count"),
SampleType::LockAcquireWait => ValueType::new("lock-acquire-wait", "nanoseconds"),
SampleType::LockCount => ValueType::new("lock-count", "count"),
SampleType::LockRelease => ValueType::new("lock-release", "count"),
SampleType::LockReleaseHold => ValueType::new("lock-release-hold", "nanoseconds"),
SampleType::LockTime => ValueType::new("lock-time", "nanoseconds"),
SampleType::ObjectsLegacy => ValueType::new("objects", "count"),
SampleType::RequestTime => ValueType::new("request-time", "nanoseconds"),
SampleType::Sample => ValueType::new("sample", "count"),
SampleType::SocketReadSize => ValueType::new("socket-read-size", "bytes"),
SampleType::SocketReadSizeSamples => {
ValueType::new("socket-read-size-samples", "count")
}
SampleType::SocketReadTime => ValueType::new("socket-read-time", "nanoseconds"),
SampleType::SocketReadTimeSamples => {
ValueType::new("socket-read-time-samples", "count")
}
SampleType::SocketWriteSize => ValueType::new("socket-write-size", "bytes"),
SampleType::SocketWriteSizeSamples => {
ValueType::new("socket-write-size-samples", "count")
}
SampleType::SocketWriteTime => ValueType::new("socket-write-time", "nanoseconds"),
SampleType::SocketWriteTimeSamples => {
ValueType::new("socket-write-time-samples", "count")
}
SampleType::SpaceLegacy => ValueType::new("space", "bytes"),
SampleType::Timeline => ValueType::new("timeline", "nanoseconds"),
SampleType::WallSamples => ValueType::new("wall-samples", "count"),
SampleType::WallTime => ValueType::new("wall-time", "nanoseconds"),
SampleType::WallLegacy => ValueType::new("wall", "nanoseconds"),
SampleType::ExperimentalCount => ValueType::new("experimental-count", "count"),
SampleType::ExperimentalNanoseconds => {
ValueType::new("experimental-nanoseconds", "nanoseconds")
}
SampleType::ExperimentalBytes => ValueType::new("experimental-bytes", "bytes"),
}
}
}

impl<'a> TryFrom<ValueType<'a>> for SampleType {
type Error = anyhow::Error;

fn try_from(vt: ValueType<'a>) -> Result<Self, Self::Error> {
Ok(match (vt.r#type, vt.unit) {
("alloc-samples", "count") => SampleType::AllocSamples,
("alloc-samples-unscaled", "count") => SampleType::AllocSamplesUnscaled,
("alloc-size", "bytes") => SampleType::AllocSize,
("alloc-space", "bytes") => SampleType::AllocSpace,
("cpu-time", "nanoseconds") => SampleType::CpuTime,
("cpu-samples", "count") => SampleType::CpuSamples,
("cpu", "nanoseconds") => SampleType::CpuLegacy,
("cpu-sample", "count") => SampleType::CpuSampleLegacy,
("exception-samples", "count") => SampleType::ExceptionSamples,
("exception", "count") => SampleType::ExceptionLegacy,
("file-io-read-size", "bytes") => SampleType::FileIoReadSize,
("file-io-read-size-samples", "count") => SampleType::FileIoReadSizeSamples,
("file-io-read-time", "nanoseconds") => SampleType::FileIoReadTime,
("file-io-read-time-samples", "count") => SampleType::FileIoReadTimeSamples,
("file-io-write-size", "bytes") => SampleType::FileIoWriteSize,
("file-io-write-size-samples", "count") => SampleType::FileIoWriteSizeSamples,
("file-io-write-time", "nanoseconds") => SampleType::FileIoWriteTime,
("file-io-write-time-samples", "count") => SampleType::FileIoWriteTimeSamples,
("gpu-alloc-samples", "count") => SampleType::GpuAllocSamples,
("gpu-flops", "count") => SampleType::GpuFlops,
("gpu-flops-samples", "count") => SampleType::GpuFlopsSamples,
("gpu-samples", "count") => SampleType::GpuSamples,
("gpu-space", "bytes") => SampleType::GpuSpace,
("gpu-time", "nanoseconds") => SampleType::GpuTime,
("heap-live-samples", "count") => SampleType::HeapLiveSamples,
("heap-live-size", "bytes") => SampleType::HeapLiveSize,
("heap-space", "bytes") => SampleType::HeapSpace,
("inuse-objects", "count") => SampleType::InuseObjects,
("inuse-space", "bytes") => SampleType::InuseSpace,
("lock-acquire", "count") => SampleType::LockAcquire,
("lock-acquire-wait", "nanoseconds") => SampleType::LockAcquireWait,
("lock-count", "count") => SampleType::LockCount,
("lock-release", "count") => SampleType::LockRelease,
("lock-release-hold", "nanoseconds") => SampleType::LockReleaseHold,
("lock-time", "nanoseconds") => SampleType::LockTime,
("objects", "count") => SampleType::ObjectsLegacy,
("request-time", "nanoseconds") => SampleType::RequestTime,
("sample", "count") => SampleType::Sample,
("socket-read-size", "bytes") => SampleType::SocketReadSize,
("socket-read-size-samples", "count") => SampleType::SocketReadSizeSamples,
("socket-read-time", "nanoseconds") => SampleType::SocketReadTime,
("socket-read-time-samples", "count") => SampleType::SocketReadTimeSamples,
("socket-write-size", "bytes") => SampleType::SocketWriteSize,
("socket-write-size-samples", "count") => SampleType::SocketWriteSizeSamples,
("socket-write-time", "nanoseconds") => SampleType::SocketWriteTime,
("socket-write-time-samples", "count") => SampleType::SocketWriteTimeSamples,
("space", "bytes") => SampleType::SpaceLegacy,
("timeline", "nanoseconds") => SampleType::Timeline,
("wall-samples", "count") => SampleType::WallSamples,
("wall-time", "nanoseconds") => SampleType::WallTime,
("wall", "nanoseconds") => SampleType::WallLegacy,
("experimental-count", "count") => SampleType::ExperimentalCount,
("experimental-nanoseconds", "nanoseconds") => SampleType::ExperimentalNanoseconds,
("experimental-bytes", "bytes") => SampleType::ExperimentalBytes,
_ => anyhow::bail!("Unknown sample type: ({}, {})", vt.r#type, vt.unit),
})
}
}

#[cfg(test)]
mod tests {
use super::*;
use strum::IntoEnumIterator;

#[test]
fn sample_type_round_trip_conversion() {
// Test that converting SampleType -> ValueType -> SampleType gives the same result
// Uses strum::EnumIter to automatically iterate over all variants
for original in SampleType::iter() {
let value_type: ValueType = original.into();
let round_trip: SampleType = value_type.try_into().expect("round-trip conversion");
assert_eq!(original, round_trip);
}
}

#[test]
fn value_type_to_sample_type_unknown_type() {
// Test that unknown type/unit combinations fail gracefully
let unknown = ValueType::new("unknown-type", "count");
let result: Result<SampleType, _> = unknown.try_into();
assert!(result.is_err(), "Unknown type should fail to parse");
assert!(result
.unwrap_err()
.to_string()
.contains("Unknown sample type"));

let invalid_unit = ValueType::new("cpu-time", "count");
let result: Result<SampleType, _> = invalid_unit.try_into();
assert!(
result.is_err(),
"Invalid unit for known type should fail to parse"
);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

So this gets into my "rust-foo" not being amazing but I'm not sure why we're doing the weird enum + separate impl vs how https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html does it which is a bit closer to what I was expecting to see when I got to this file.

Are the advantages/disadvantages from doing this the other way?

Comment on lines +18 to +38
// Shared types - CXX-friendly types
//
// This enum covers the ValueType entries supported by Datadog profilers:
// - dd-trace-rb (stack_recorder.c `all_value_types`)
// - dd-trace-py (dd_wrapper/include/types.hpp + dd_wrapper/src/profile.cpp value strings)
// - dd-trace-php (profiling/src/profiling/samples.rs I/O profiling sample types)
// - dd-trace-dotnet (sample type definitions for allocations, locks, CPU, walltime, exceptions,
// live objects, HTTP requests)
// - pprof-nodejs (profile-serializer.ts value type functions)
//
// Experimental variants allow profilers to use custom sample types for testing
// and development without modifying this enum. They map to fixed (type, unit) pairs.
//
// LEGACY VARIANTS (prefer alternatives for consistency):
// - CpuLegacy (use CpuTime)
// - CpuSampleLegacy (use CpuSamples)
// - ExceptionLegacy (use ExceptionSamples)
// - ObjectsLegacy (use InuseObjects)
// - SpaceLegacy (use specific variants: InuseSpace, HeapSpace, AllocSpace)
// - WallLegacy (use WallTime)
enum SampleType {
Copy link
Member

Choose a reason for hiding this comment

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

It's not clear to me -- why does this need to be different for c++?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CXX limitations. It requires that types used in the cxx bridge be defined there.

  1. CXX is currently feature flagged to avoid increasing binary size/ build times for runtimes that don't use it
  2. declaring internal types inside an API layer felt wrong, so I used the same pattern as C where we have extern types which convert to internal types.

I could change this and make the cxx representation be the source of truth, but for now this way felt better.

Comment on lines -44 to -46
/// When profiles are reset, the period needs to be preserved. This
/// stores it in a way that does not depend on the string table.
owned_period: Option<owned_types::Period>,
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious, why change the period as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that we have a structured enum, might as well use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants