Add ParentBasedAlwaysOnSampler as default sampler for OTLP trace export mode#10915
Add ParentBasedAlwaysOnSampler as default sampler for OTLP trace export mode#10915
Conversation
…r for otlp mode, instead of priority sampling or traces rate based sampler. plus tests
|
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
dd-trace-core/src/test/groovy/datadog/trace/common/sampling/SamplerTest.groovy
Outdated
Show resolved
Hide resolved
| log.error("Invalid sampler configuration. Using AllSampler", e); | ||
| sampler = new AllSampler(); | ||
| } | ||
| // TODO: if OTLP trace export enabled, select ParentBasedAlwaysOnSampler here |
There was a problem hiding this comment.
You can use config.isTraceOtlpExporterEnabled() here
| import static datadog.trace.api.sampling.PrioritySampling.USER_DROP | ||
| import static datadog.trace.api.sampling.PrioritySampling.USER_KEEP | ||
|
|
||
| class ParentBasedAlwaysOnSamplerTest extends DDCoreSpecification { |
There was a problem hiding this comment.
optional: Consider to rewrite this test as Java JUnit test (since we are trying to migrate from Groovy Spock to Java JUnit5). You may check with @sarahchen6 on this, she is working on migration from Groovy to Java and can share some hints.
There was a problem hiding this comment.
JUnit would be ideal 🙏 . There is the migrate-groovy-to-java Claude skill you could also try on this file to automatically migrate the tests over
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 65 metrics, 6 unstable metrics. Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.61.0-SNAPSHOT~f3bc0c8bb1, baseline=1.61.0-SNAPSHOT~828c9cc58f
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.063 s) : 0, 1063312
Total [baseline] (8.886 s) : 0, 8886493
Agent [candidate] (1.066 s) : 0, 1065633
Total [candidate] (8.854 s) : 0, 8854025
section iast
Agent [baseline] (1.238 s) : 0, 1237535
Total [baseline] (9.558 s) : 0, 9557561
Agent [candidate] (1.225 s) : 0, 1225499
Total [candidate] (9.574 s) : 0, 9573907
gantt
title insecure-bank - break down per module: candidate=1.61.0-SNAPSHOT~f3bc0c8bb1, baseline=1.61.0-SNAPSHOT~828c9cc58f
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.211 ms) : 0, 1211
crashtracking [candidate] (1.226 ms) : 0, 1226
BytebuddyAgent [baseline] (633.05 ms) : 0, 633050
BytebuddyAgent [candidate] (635.084 ms) : 0, 635084
AgentMeter [baseline] (29.652 ms) : 0, 29652
AgentMeter [candidate] (29.496 ms) : 0, 29496
GlobalTracer [baseline] (258.451 ms) : 0, 258451
GlobalTracer [candidate] (258.176 ms) : 0, 258176
AppSec [baseline] (31.901 ms) : 0, 31901
AppSec [candidate] (31.852 ms) : 0, 31852
Debugger [baseline] (59.851 ms) : 0, 59851
Debugger [candidate] (59.811 ms) : 0, 59811
Remote Config [baseline] (596.661 µs) : 0, 597
Remote Config [candidate] (588.488 µs) : 0, 588
Telemetry [baseline] (8.057 ms) : 0, 8057
Telemetry [candidate] (8.843 ms) : 0, 8843
Flare Poller [baseline] (4.299 ms) : 0, 4299
Flare Poller [candidate] (4.37 ms) : 0, 4370
section iast
crashtracking [baseline] (1.203 ms) : 0, 1203
crashtracking [candidate] (1.188 ms) : 0, 1188
BytebuddyAgent [baseline] (803.816 ms) : 0, 803816
BytebuddyAgent [candidate] (795.628 ms) : 0, 795628
AgentMeter [baseline] (11.597 ms) : 0, 11597
AgentMeter [candidate] (11.383 ms) : 0, 11383
GlobalTracer [baseline] (248.801 ms) : 0, 248801
GlobalTracer [candidate] (246.687 ms) : 0, 246687
IAST [baseline] (25.647 ms) : 0, 25647
IAST [candidate] (25.278 ms) : 0, 25278
AppSec [baseline] (26.811 ms) : 0, 26811
AppSec [candidate] (26.482 ms) : 0, 26482
Debugger [baseline] (69.437 ms) : 0, 69437
Debugger [candidate] (68.271 ms) : 0, 68271
Remote Config [baseline] (537.315 µs) : 0, 537
Remote Config [candidate] (537.964 µs) : 0, 538
Telemetry [baseline] (9.713 ms) : 0, 9713
Telemetry [candidate] (10.224 ms) : 0, 10224
Flare Poller [baseline] (3.5 ms) : 0, 3500
Flare Poller [candidate] (3.695 ms) : 0, 3695
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.61.0-SNAPSHOT~f3bc0c8bb1, baseline=1.61.0-SNAPSHOT~828c9cc58f
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.06 s) : 0, 1059533
Total [baseline] (11.031 s) : 0, 11031054
Agent [candidate] (1.057 s) : 0, 1057464
Total [candidate] (11.08 s) : 0, 11080074
section appsec
Agent [baseline] (1.249 s) : 0, 1248660
Total [baseline] (11.225 s) : 0, 11225134
Agent [candidate] (1.25 s) : 0, 1250014
Total [candidate] (11.2 s) : 0, 11199943
section iast
Agent [baseline] (1.231 s) : 0, 1231301
Total [baseline] (11.219 s) : 0, 11218987
Agent [candidate] (1.23 s) : 0, 1229893
Total [candidate] (11.309 s) : 0, 11308795
section profiling
Agent [baseline] (1.185 s) : 0, 1185025
Total [baseline] (11.011 s) : 0, 11010521
Agent [candidate] (1.183 s) : 0, 1182859
Total [candidate] (11.057 s) : 0, 11056782
gantt
title petclinic - break down per module: candidate=1.61.0-SNAPSHOT~f3bc0c8bb1, baseline=1.61.0-SNAPSHOT~828c9cc58f
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.212 ms) : 0, 1212
crashtracking [candidate] (1.19 ms) : 0, 1190
BytebuddyAgent [baseline] (632.094 ms) : 0, 632094
BytebuddyAgent [candidate] (629.454 ms) : 0, 629454
AgentMeter [baseline] (29.257 ms) : 0, 29257
AgentMeter [candidate] (29.336 ms) : 0, 29336
GlobalTracer [baseline] (256.752 ms) : 0, 256752
GlobalTracer [candidate] (257.096 ms) : 0, 257096
AppSec [baseline] (31.776 ms) : 0, 31776
AppSec [candidate] (31.797 ms) : 0, 31797
Debugger [baseline] (60.292 ms) : 0, 60292
Debugger [candidate] (60.47 ms) : 0, 60470
Remote Config [baseline] (592.079 µs) : 0, 592
Remote Config [candidate] (592.43 µs) : 0, 592
Telemetry [baseline] (7.974 ms) : 0, 7974
Telemetry [candidate] (7.986 ms) : 0, 7986
Flare Poller [baseline] (3.473 ms) : 0, 3473
Flare Poller [candidate] (3.498 ms) : 0, 3498
section appsec
crashtracking [baseline] (1.195 ms) : 0, 1195
crashtracking [candidate] (1.191 ms) : 0, 1191
BytebuddyAgent [baseline] (659.279 ms) : 0, 659279
BytebuddyAgent [candidate] (660.513 ms) : 0, 660513
AgentMeter [baseline] (12.119 ms) : 0, 12119
AgentMeter [candidate] (12.156 ms) : 0, 12156
GlobalTracer [baseline] (258.348 ms) : 0, 258348
GlobalTracer [candidate] (258.843 ms) : 0, 258843
AppSec [baseline] (178.114 ms) : 0, 178114
AppSec [candidate] (178.025 ms) : 0, 178025
Debugger [baseline] (66.398 ms) : 0, 66398
Debugger [candidate] (66.089 ms) : 0, 66089
Remote Config [baseline] (619.84 µs) : 0, 620
Remote Config [candidate] (632.549 µs) : 0, 633
Telemetry [baseline] (8.386 ms) : 0, 8386
Telemetry [candidate] (8.336 ms) : 0, 8336
Flare Poller [baseline] (3.646 ms) : 0, 3646
Flare Poller [candidate] (3.643 ms) : 0, 3643
IAST [baseline] (24.218 ms) : 0, 24218
IAST [candidate] (24.28 ms) : 0, 24280
section iast
crashtracking [baseline] (1.197 ms) : 0, 1197
crashtracking [candidate] (1.222 ms) : 0, 1222
BytebuddyAgent [baseline] (798.078 ms) : 0, 798078
BytebuddyAgent [candidate] (797.422 ms) : 0, 797422
AgentMeter [baseline] (11.445 ms) : 0, 11445
AgentMeter [candidate] (11.418 ms) : 0, 11418
GlobalTracer [baseline] (248.024 ms) : 0, 248024
GlobalTracer [candidate] (247.76 ms) : 0, 247760
AppSec [baseline] (26.667 ms) : 0, 26667
AppSec [candidate] (27.252 ms) : 0, 27252
Debugger [baseline] (71.227 ms) : 0, 71227
Debugger [candidate] (70.221 ms) : 0, 70221
Remote Config [baseline] (532.337 µs) : 0, 532
Remote Config [candidate] (533.417 µs) : 0, 533
Telemetry [baseline] (9.18 ms) : 0, 9180
Telemetry [candidate] (9.18 ms) : 0, 9180
Flare Poller [baseline] (3.354 ms) : 0, 3354
Flare Poller [candidate] (3.353 ms) : 0, 3353
IAST [baseline] (25.473 ms) : 0, 25473
IAST [candidate] (25.365 ms) : 0, 25365
section profiling
ProfilingAgent [baseline] (93.729 ms) : 0, 93729
ProfilingAgent [candidate] (94.082 ms) : 0, 94082
crashtracking [baseline] (1.175 ms) : 0, 1175
crashtracking [candidate] (1.173 ms) : 0, 1173
BytebuddyAgent [baseline] (684.149 ms) : 0, 684149
BytebuddyAgent [candidate] (682.059 ms) : 0, 682059
AgentMeter [baseline] (9.111 ms) : 0, 9111
AgentMeter [candidate] (9.019 ms) : 0, 9019
GlobalTracer [baseline] (215.879 ms) : 0, 215879
GlobalTracer [candidate] (215.716 ms) : 0, 215716
AppSec [baseline] (32.301 ms) : 0, 32301
AppSec [candidate] (32.153 ms) : 0, 32153
Debugger [baseline] (65.966 ms) : 0, 65966
Debugger [candidate] (65.126 ms) : 0, 65126
Remote Config [baseline] (564.986 µs) : 0, 565
Remote Config [candidate] (562.957 µs) : 0, 563
Telemetry [baseline] (7.715 ms) : 0, 7715
Telemetry [candidate] (8.523 ms) : 0, 8523
Flare Poller [baseline] (3.451 ms) : 0, 3451
Flare Poller [candidate] (3.492 ms) : 0, 3492
Profiling [baseline] (94.298 ms) : 0, 94298
Profiling [candidate] (94.645 ms) : 0, 94645
LoadParameters
See matching parameters
SummaryFound 4 performance improvements and 3 performance regressions! Performance is the same for 13 metrics, 16 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.61.0-SNAPSHOT~f3bc0c8bb1, baseline=1.61.0-SNAPSHOT~828c9cc58f
dateFormat X
axisFormat %s
section baseline
no_agent (18.614 ms) : 18420, 18807
. : milestone, 18614,
appsec (18.548 ms) : 18361, 18734
. : milestone, 18548,
code_origins (17.562 ms) : 17389, 17736
. : milestone, 17562,
iast (17.93 ms) : 17749, 18110
. : milestone, 17930,
profiling (19.923 ms) : 19716, 20129
. : milestone, 19923,
tracing (18.341 ms) : 18157, 18524
. : milestone, 18341,
section candidate
no_agent (19.205 ms) : 19009, 19401
. : milestone, 19205,
appsec (18.633 ms) : 18444, 18822
. : milestone, 18633,
code_origins (18.576 ms) : 18389, 18763
. : milestone, 18576,
iast (17.714 ms) : 17538, 17889
. : milestone, 17714,
profiling (18.571 ms) : 18383, 18758
. : milestone, 18571,
tracing (17.634 ms) : 17460, 17809
. : milestone, 17634,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.61.0-SNAPSHOT~f3bc0c8bb1, baseline=1.61.0-SNAPSHOT~828c9cc58f
dateFormat X
axisFormat %s
section baseline
no_agent (1.178 ms) : 1167, 1189
. : milestone, 1178,
iast (3.392 ms) : 3345, 3438
. : milestone, 3392,
iast_FULL (5.882 ms) : 5823, 5940
. : milestone, 5882,
iast_GLOBAL (3.501 ms) : 3444, 3559
. : milestone, 3501,
profiling (2.085 ms) : 2067, 2103
. : milestone, 2085,
tracing (1.764 ms) : 1749, 1779
. : milestone, 1764,
section candidate
no_agent (1.187 ms) : 1176, 1199
. : milestone, 1187,
iast (3.096 ms) : 3052, 3140
. : milestone, 3096,
iast_FULL (5.704 ms) : 5646, 5761
. : milestone, 5704,
iast_GLOBAL (3.68 ms) : 3614, 3745
. : milestone, 3680,
profiling (1.995 ms) : 1975, 2014
. : milestone, 1995,
tracing (1.802 ms) : 1787, 1817
. : milestone, 1802,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 1 unstable metrics. Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.61.0-SNAPSHOT~f3bc0c8bb1, baseline=1.61.0-SNAPSHOT~828c9cc58f
dateFormat X
axisFormat %s
section baseline
no_agent (14.889 s) : 14889000, 14889000
. : milestone, 14889000,
appsec (14.674 s) : 14674000, 14674000
. : milestone, 14674000,
iast (17.984 s) : 17984000, 17984000
. : milestone, 17984000,
iast_GLOBAL (17.853 s) : 17853000, 17853000
. : milestone, 17853000,
profiling (15.324 s) : 15324000, 15324000
. : milestone, 15324000,
tracing (15.083 s) : 15083000, 15083000
. : milestone, 15083000,
section candidate
no_agent (15.649 s) : 15649000, 15649000
. : milestone, 15649000,
appsec (14.798 s) : 14798000, 14798000
. : milestone, 14798000,
iast (18.494 s) : 18494000, 18494000
. : milestone, 18494000,
iast_GLOBAL (17.938 s) : 17938000, 17938000
. : milestone, 17938000,
profiling (14.995 s) : 14995000, 14995000
. : milestone, 14995000,
tracing (14.72 s) : 14720000, 14720000
. : milestone, 14720000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.61.0-SNAPSHOT~f3bc0c8bb1, baseline=1.61.0-SNAPSHOT~828c9cc58f
dateFormat X
axisFormat %s
section baseline
no_agent (1.466 ms) : 1455, 1478
. : milestone, 1466,
appsec (3.766 ms) : 3544, 3988
. : milestone, 3766,
iast (2.242 ms) : 2173, 2311
. : milestone, 2242,
iast_GLOBAL (2.281 ms) : 2212, 2350
. : milestone, 2281,
profiling (2.106 ms) : 2049, 2162
. : milestone, 2106,
tracing (2.061 ms) : 2007, 2114
. : milestone, 2061,
section candidate
no_agent (1.469 ms) : 1457, 1480
. : milestone, 1469,
appsec (3.788 ms) : 3568, 4009
. : milestone, 3788,
iast (2.24 ms) : 2171, 2308
. : milestone, 2240,
iast_GLOBAL (2.278 ms) : 2210, 2347
. : milestone, 2278,
profiling (2.099 ms) : 2043, 2156
. : milestone, 2099,
tracing (2.049 ms) : 1995, 2102
. : milestone, 2049,
|
| static Stream<Arguments> childSpanInheritsSamplingDecisionFromRemoteParentArguments() { | ||
| return Stream.of( | ||
| Arguments.arguments("sampler keep", SAMPLER_KEEP), | ||
| Arguments.arguments("sampler drop", SAMPLER_DROP), | ||
| Arguments.arguments("user keep", USER_KEEP), | ||
| Arguments.arguments("user drop", USER_DROP)); | ||
| } |
There was a problem hiding this comment.
Nice rework to JUnit!
Let's use @TableTest instead of @MethodSource, you can use as example
What Does This Do
Adds a
ParentBasedAlwaysOnSamplerthat will be used as the default sampler when OTLP trace export is enabled and no user-defined sampling rules are configured. In this mode, child spans inherit sampling decision from their parent, but new root spans are always kept.This PR is just one part of the OTLP Export Implementation -- Phase 1.
Motivation
When exporting traces via OTLP, there is no Datadog Agent to back-propagate sampling rates. This PR adds the OpenTelemetry-standard
parentbased_always_on(ref) fallback sampler, ensuring traces are sampled at 100% by default while still respecting user-configured rules.Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]
Note: Once your PR is ready to merge, add it to the merge queue by commenting
/merge./merge -ccancels the queue request./merge -f --reason "reason"skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.