Skip to content

Fix flaky exposure shutdown flush test - #9396

Merged
btthomas merged 1 commit into
masterfrom
dd/fix-exposure-dispose-flaky-test
Oct 9, 2026
Merged

btthomas merged 1 commit into
masterfrom
dd/fix-exposure-dispose-flaky-test

Conversation

@btthomas

@btthomas btthomas commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Summary of changes

  • Increase the shutdown allowance in DisposeFlushesEventsQueuedWhileAnEarlierBatchIsSending from 5 seconds to 1 minute and explain its purpose.

Reason for change

Under thread-pool starvation, the test's async continuations can run after Dispose's wall-clock shutdown timeout expires. This causes the assertion that Dispose is still waiting for the final batch to fail even though the production behavior is correct. Azure build 210959 reported this failure after 5.02 seconds, matching the previous 5-second allowance.

Implementation details

The longer allowance accommodates scheduling delays while the test coordinates the two blocked sends. All synchronization and assertions remain unchanged, including checking that Dispose waits for the final send and that the queued exposure is flushed. Production shutdown behavior and the separate bounded-wait test remain unchanged.

Test coverage

Source comparison verified that only this test's shutdown allowance and explanatory comment changed. Attempted the focused ExposureApiTests on net8.0, but execution was blocked before build: global.json requires .NET SDK 11.0.100-rc.1.26425.128 and the sandbox only has SDK 8.0.412. No local reproduction or passing test run is claimed; CI validation is still required.

Other details

The affected test was introduced in #9353.


PR by Bits - View session in Datadog

Comment @DataDog to request changes

Co-authored-by: btthomas <9452950+btthomas@users.noreply.github.com>
@btthomas
btthomas requested a review from a team as a code owner October 9, 2026 19:10
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

View session in Datadog

Bits Code status: ✅ Done

Comment @DataDog to request changes

@btthomas
btthomas requested review from leoromanovsky and removed request for a team October 9, 2026 19:10
@btthomas
btthomas requested a review from greghuels October 9, 2026 19:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T19:11:30.256426Z 08f3d97 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the area:tests unit tests, integration tests label Oct 9, 2026

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

The test retains its checks that Dispose waits for the final blocked send and flushes the queued exposure. The longer allowance accommodates delayed continuations without changing production shutdown behavior.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 08f3d97

@btthomas
btthomas enabled auto-merge (squash) October 9, 2026 19:20
@dd-trace-dotnet-ci-bot

Copy link
Copy Markdown

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (9396) and master.

✅ No regressions detected

📄 View the full report (charts + all metrics) →

@btthomas
btthomas merged commit a38d3ec into master Oct 9, 2026
146 of 151 checks passed
@btthomas
btthomas deleted the dd/fix-exposure-dispose-flaky-test branch October 9, 2026 20:27
@github-actions github-actions Bot added this to the vNext-v3 milestone Oct 9, 2026
@pr-commenter

pr-commenter Bot commented Oct 9, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-10-09 20:31:20

Comparing candidate commit 08f3d97 in PR branch dd/fix-exposure-dispose-flaky-test with baseline commit 1000e3f in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 11 performance regressions! Performance is the same for 61 metrics, 0 unstable metrics, 74 known flaky benchmarks, 52 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery net472

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+10.133%; +10.144%]
  • 🟥 throughput [-30680.710op/s; -27596.556op/s] or [-8.641%; -7.773%]

scenario:Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery net6.0

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+9.750%; +9.761%]

scenario:Benchmarks.Trace.DbCommandBenchmark.ExecuteNonQuery netcoreapp3.1

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+9.830%; +9.841%]
  • 🟥 throughput [-32868.256op/s; -23833.159op/s] or [-8.124%; -5.891%]

scenario:Benchmarks.Trace.HttpClientBenchmark.SendAsync net472

  • 🟥 allocated_mem [+271 bytes; +272 bytes] or [+9.338%; +9.348%]
  • 🟥 throughput [-12705.204op/s; -11919.441op/s] or [-14.504%; -13.607%]

scenario:Benchmarks.Trace.HttpClientBenchmark.SendAsync net6.0

  • 🟥 allocated_mem [+199 bytes; +200 bytes] or [+9.426%; +9.438%]

scenario:Benchmarks.Trace.HttpClientBenchmark.SendAsync netcoreapp3.1

  • 🟥 allocated_mem [+199 bytes; +200 bytes] or [+7.569%; +7.581%]
  • 🟥 throughput [-13919.441op/s; -12523.858op/s] or [-11.046%; -9.938%]

scenario:Benchmarks.Trace.NLogBenchmark.EnrichedLog net472

  • 🟥 throughput [-8191.195op/s; -7009.249op/s] or [-6.275%; -5.369%]

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net472

  • 🟥 throughput [-10169.438op/s; -9116.136op/s] or [-12.058%; -10.809%]

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild netcoreapp3.1

  • 🟥 throughput [-13072.573op/s; -11683.504op/s] or [-13.292%; -11.880%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 allocated_mem [+1.541KB; +1.541KB] or [+46.817%; +46.831%]
  • 🟥 execution_time [+304.818ms; +307.625ms] or [+151.262%; +152.654%]
  • 🟥 throughput [-53.703op/s; -49.434op/s] or [-9.662%; -8.894%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • 🟥 allocated_mem [+1.011KB; +1.011KB] or [+37.485%; +37.498%]
  • 🟥 execution_time [+381.442ms; +384.448ms] or [+301.363%; +303.737%]
  • 🟩 throughput [+66.345op/s; +74.862op/s] or [+8.747%; +9.870%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟥 allocated_mem [+1.090KB; +1.090KB] or [+40.417%; +40.429%]
  • 🟥 execution_time [+388.878ms; +393.681ms] or [+344.142%; +348.392%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net472

  • 🟥 allocated_mem [+4.758KB; +4.758KB] or [+100.159%; +100.174%]
  • 🟥 throughput [-62553.526op/s; -62138.310op/s] or [-48.670%; -48.347%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net6.0

  • 🟥 allocated_mem [+3.880KB; +3.880KB] or [+82.058%; +82.072%]
  • 🟩 execution_time [-15.959ms; -11.760ms] or [-7.453%; -5.492%]
  • 🟥 throughput [-62221.490op/s; -59395.057op/s] or [-45.418%; -43.355%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody netcoreapp3.1

  • 🟥 allocated_mem [+4.608KB; +4.608KB] or [+99.641%; +99.654%]
  • 🟥 throughput [-48835.850op/s; -46584.108op/s] or [-44.153%; -42.117%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net472

  • 🟥 allocated_mem [+1.380KB; +1.380KB] or [+111.648%; +111.662%]
  • 🟥 throughput [-350466.119op/s; -345871.366op/s] or [-35.784%; -35.315%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net6.0

  • 🟥 allocated_mem [+543 bytes; +544 bytes] or [+44.437%; +44.446%]
  • 🟩 execution_time [-26.446ms; -21.559ms] or [-11.794%; -9.615%]
  • 🟥 throughput [-106098.087op/s; -82856.082op/s] or [-11.335%; -8.852%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody netcoreapp3.1

  • 🟥 allocated_mem [+1.344KB; +1.344KB] or [+111.253%; +111.267%]
  • 🟥 throughput [-179286.387op/s; -163541.152op/s] or [-25.760%; -23.498%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net472

  • 🟥 allocated_mem [+3.378KB; +3.378KB] or [+89.003%; +89.017%]
  • 🟥 throughput [-76820.871op/s; -76033.359op/s] or [-51.700%; -51.170%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net6.0

  • 🟥 allocated_mem [+3.336KB; +3.336KB] or [+88.150%; +88.161%]
  • 🟥 throughput [-75355.100op/s; -72479.049op/s] or [-47.947%; -46.117%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody netcoreapp3.1

  • 🟥 allocated_mem [+3.264KB; +3.264KB] or [+88.493%; +88.506%]
  • 🟥 throughput [-56100.394op/s; -53484.437op/s] or [-44.691%; -42.607%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net472

  • 🟥 throughput [-282010.393op/s; -263040.979op/s] or [-8.579%; -8.002%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net6.0

  • 🟩 throughput [+151429.487op/s; +194239.419op/s] or [+5.049%; +6.477%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1

  • 🟩 execution_time [-18.901ms; -14.565ms] or [-8.713%; -6.714%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net472

  • 🟩 allocated_mem [-13.759KB; -13.757KB] or [-42.326%; -42.318%]
  • 🟥 execution_time [+300.175ms; +301.022ms] or [+149.987%; +150.411%]
  • 🟩 throughput [+931.683op/s; +950.426op/s] or [+10.290%; +10.497%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net6.0

  • 🟩 allocated_mem [-13.722KB; -13.718KB] or [-42.341%; -42.329%]
  • 🟥 execution_time [+300.691ms; +303.888ms] or [+151.639%; +153.251%]
  • 🟩 throughput [+2178.794op/s; +2395.247op/s] or [+16.665%; +18.320%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs netcoreapp3.1

  • 🟩 allocated_mem [-13.722KB; -13.718KB] or [-42.341%; -42.329%]
  • 🟥 execution_time [+301.055ms; +304.370ms] or [+151.648%; +153.318%]
  • 🟩 throughput [+1716.835op/s; +1854.781op/s] or [+16.575%; +17.907%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net472

  • 🟥 execution_time [+296.543ms; +297.095ms] or [+145.650%; +145.922%]
  • 🟩 throughput [+565.166op/s; +574.577op/s] or [+14.983%; +15.232%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net6.0

  • 🟥 execution_time [+295.589ms; +298.067ms] or [+144.503%; +145.714%]
  • 🟩 throughput [+2751.344op/s; +2796.356op/s] or [+39.972%; +40.626%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs netcoreapp3.1

  • 🟥 execution_time [+300.544ms; +301.628ms] or [+150.212%; +150.753%]
  • 🟩 throughput [+1364.907op/s; +1406.171op/s] or [+27.092%; +27.911%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net472

  • 🟩 execution_time [-145.325µs; -141.423µs] or [-29.837%; -29.036%]
  • 🟩 throughput [+844.321op/s; +869.669op/s] or [+41.122%; +42.357%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net6.0

  • 🟩 execution_time [-123.576µs; -96.663µs] or [-28.342%; -22.170%]
  • 🟩 throughput [+706.981op/s; +833.413op/s] or [+30.737%; +36.234%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark netcoreapp3.1

  • 🟩 execution_time [-143.509µs; -121.503µs] or [-30.747%; -26.032%]
  • 🟩 throughput [+784.630op/s; +867.613op/s] or [+36.220%; +40.051%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net472

  • 🟩 execution_time [-128.000µs; -124.172µs] or [-34.559%; -33.525%]
  • 🟩 throughput [+1374.345op/s; +1413.838op/s] or [+50.899%; +52.362%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net6.0

  • 🟩 execution_time [-95.694µs; -71.505µs] or [-30.550%; -22.828%]
  • 🟩 throughput [+1043.783op/s; +1265.589op/s] or [+32.538%; +39.452%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack netcoreapp3.1

  • 🟩 execution_time [-138.231µs; -115.849µs] or [-37.815%; -31.692%]
  • 🟩 throughput [+1338.547op/s; +1475.234op/s] or [+48.035%; +52.940%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+299.699ms; +300.313ms] or [+149.580%; +149.887%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net6.0

  • 🟥 execution_time [+412.739ms; +421.800ms] or [+448.458%; +458.303%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest netcoreapp3.1

  • unstable execution_time [+253.795ms; +306.227ms] or [+192.704%; +232.515%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 allocated_mem [+2.848KB; +2.853KB] or [+5.060%; +5.069%]
  • unstable execution_time [+261.713ms; +322.582ms] or [+120.333%; +148.320%]
  • 🟥 throughput [-551.785op/s; -493.437op/s] or [-49.997%; -44.710%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • unstable execution_time [+207.173ms; +340.477ms] or [+88.289%; +145.097%]
  • 🟥 throughput [-672.463op/s; -589.002op/s] or [-44.853%; -39.287%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟥 execution_time [+352.965ms; +361.150ms] or [+211.114%; +216.010%]
  • 🟥 throughput [-477.035op/s; -441.721op/s] or [-33.215%; -30.756%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool netcoreapp3.1

  • unstable throughput [-0.481op/s; +88.793op/s] or [-0.090%; +16.574%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net6.0

  • 🟩 execution_time [-166.724µs; -150.729µs] or [-8.446%; -7.635%]
  • 🟩 throughput [+41.985op/s; +46.865op/s] or [+8.288%; +9.251%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 allocated_mem [+96 bytes; +97 bytes] or [+12.092%; +12.103%]
  • 🟥 execution_time [+302.933ms; +304.413ms] or [+152.551%; +153.297%]
  • 🟥 throughput [-27523.658op/s; -23256.546op/s] or [-8.856%; -7.483%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net6.0

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+12.114%; +12.124%]
  • 🟥 execution_time [+302.203ms; +304.258ms] or [+151.434%; +152.464%]
  • 🟥 throughput [-41911.075op/s; -35539.431op/s] or [-6.608%; -5.603%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch netcoreapp3.1

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+12.114%; +12.124%]
  • 🟥 execution_time [+301.820ms; +304.816ms] or [+151.622%; +153.127%]
  • 🟥 throughput [-37235.232op/s; -28952.530op/s] or [-7.844%; -6.099%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+11.165%; +11.177%]
  • 🟥 execution_time [+301.578ms; +303.515ms] or [+151.442%; +152.415%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net6.0

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+12.493%; +12.506%]
  • 🟥 execution_time [+298.036ms; +299.429ms] or [+147.365%; +148.054%]
  • 🟥 throughput [-57599.745op/s; -52281.828op/s] or [-9.280%; -8.424%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync netcoreapp3.1

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+11.422%; +11.434%]
  • 🟥 execution_time [+301.974ms; +305.419ms] or [+153.053%; +154.800%]
  • 🟥 throughput [-36129.342op/s; -28043.678op/s] or [-7.802%; -6.056%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 allocated_mem [+96 bytes; +97 bytes] or [+11.197%; +11.208%]
  • 🟥 execution_time [+298.894ms; +300.954ms] or [+150.018%; +151.052%]
  • 🟥 throughput [-27933.724op/s; -24718.978op/s] or [-7.247%; -6.413%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net6.0

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+10.618%; +10.631%]
  • 🟥 execution_time [+301.683ms; +304.390ms] or [+150.362%; +151.711%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync netcoreapp3.1

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+10.618%; +10.631%]
  • 🟥 execution_time [+299.904ms; +304.264ms] or [+149.200%; +151.369%]

scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net472

  • 🟥 allocated_mem [+96 bytes; +97 bytes] or [+6.002%; +6.011%]
  • 🟥 throughput [-17965.898op/s; -14931.433op/s] or [-7.225%; -6.004%]

scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net6.0

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+5.627%; +5.636%]
  • 🟩 execution_time [-16.859ms; -13.206ms] or [-7.840%; -6.141%]

scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+5.605%; +5.617%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net472

  • unstable execution_time [-3.650µs; +39.308µs] or [-0.901%; +9.709%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net6.0

  • 🟩 allocated_mem [-20.912KB; -20.888KB] or [-7.628%; -7.620%]
  • unstable execution_time [-66.709µs; -11.540µs] or [-13.185%; -2.281%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark netcoreapp3.1

  • unstable execution_time [-89.812µs; -31.473µs] or [-15.564%; -5.454%]
  • 🟩 throughput [+119.356op/s; +283.070op/s] or [+6.819%; +16.172%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net6.0

  • 🟥 execution_time [+3.043µs; +6.660µs] or [+7.193%; +15.741%]
  • 🟥 throughput [-3361.657op/s; -1634.220op/s] or [-14.152%; -6.880%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark netcoreapp3.1

  • unstable execution_time [-18.246µs; -11.784µs] or [-28.308%; -18.283%]
  • 🟩 throughput [+3283.365op/s; +4594.124op/s] or [+20.145%; +28.186%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+303.779ms; +305.253ms] or [+153.547%; +154.292%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+302.319ms; +305.062ms] or [+153.879%; +155.275%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+298.979ms; +302.212ms] or [+149.676%; +151.294%]

scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net472

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+9.197%; +9.208%]
  • 🟥 throughput [-43854.612op/s; -42260.731op/s] or [-12.140%; -11.699%]

scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net6.0

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+9.226%; +9.238%]

scenario:Benchmarks.Trace.RedisBenchmark.SendReceive netcoreapp3.1

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+9.226%; +9.238%]
  • 🟥 throughput [-32345.500op/s; -23905.174op/s] or [-7.655%; -5.658%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+300.045ms; +301.912ms] or [+149.545%; +150.476%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net6.0

  • 🟥 allocated_mem [+96 bytes; +96 bytes] or [+6.000%; +6.010%]
  • 🟥 execution_time [+300.360ms; +301.962ms] or [+150.826%; +151.631%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+5.819%; +5.828%]
  • 🟥 execution_time [+302.626ms; +304.938ms] or [+153.472%; +154.645%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+299.806ms; +300.645ms] or [+149.545%; +149.963%]
  • 🟩 throughput [+65351514.277op/s; +65628237.070op/s] or [+47.593%; +47.795%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net6.0

  • 🟥 execution_time [+418.240ms; +424.057ms] or [+520.156%; +527.391%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore netcoreapp3.1

  • 🟥 execution_time [+299.188ms; +300.171ms] or [+149.228%; +149.718%]
  • 🟩 throughput [+18911282.192op/s; +19871274.906op/s] or [+8.376%; +8.802%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net472

  • 🟥 allocated_mem [+31 bytes; +32 bytes] or [+5.244%; +5.256%]
  • 🟥 throughput [-104602.642op/s; -97526.647op/s] or [-11.674%; -10.884%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net472

  • 🟥 allocated_mem [+31 bytes; +32 bytes] or [+6.037%; +6.047%]
  • 🟥 throughput [-172610.275op/s; -168896.405op/s] or [-15.801%; -15.461%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net6.0

  • 🟥 allocated_mem [+31 bytes; +32 bytes] or [+6.057%; +6.065%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan netcoreapp3.1

  • 🟥 allocated_mem [+31 bytes; +32 bytes] or [+6.059%; +6.069%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net472

  • 🟥 throughput [-35179.080op/s; -32200.685op/s] or [-7.838%; -7.174%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net472

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+15.733%; +15.745%]
  • 🟥 throughput [-68214.351op/s; -59740.439op/s] or [-9.984%; -8.743%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net6.0

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+14.810%; +14.823%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

  • 🟥 allocated_mem [+95 bytes; +96 bytes] or [+14.810%; +14.821%]
  • 🟥 throughput [-64615.085op/s; -49217.385op/s] or [-9.022%; -6.872%]

Known flaky benchmarks without significant changes:

  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net6.0
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope netcoreapp3.1
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net6.0
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes netcoreapp3.1

btthomas added a commit that referenced this pull request Oct 13, 2026
<!-- dd-meta
{"pullId":"868cb8f4-5fff-4bc3-8350-e1f82aae9dc3","source":"chat","resourceId":"a2d9735b-f842-47ff-bbc6-6c14a63ead5c","workflowId":"5cfb2560-8f04-4df3-8daf-00ca5ee3a178","codeChangeId":"5cfb2560-8f04-4df3-8daf-00ca5ee3a178","sourceType":"code_channel"}
-->
## Summary of changes

- Make the exposure shutdown flush test use its send gates to control
disposal completion.
- Run its synchronous Dispose call on a dedicated thread so it does not
occupy a worker needed by the send loop or test continuations.

## Reason for change

DisposeFlushesEventsQueuedWhileAnEarlierBatchIsSending assumes Dispose
remains blocked until the test releases the final request. However, the
test configured a finite shutdown timeout. Dispose intentionally stops
waiting when that deadline expires, even if a request remains blocked.
If thread-pool scheduling delays the test's continuation, its assertion
observes a completed Dispose task after the deadline and incorrectly
reports a flush failure. The approximately five-second failed runs match
the original five-second shutdown allowance.

Current master already contains #9396, which raised that allowance to
one minute. That reduces the chance of failure but retains the same
race. The send loop already awaits the final flush, and Dispose waits
for that loop until the configured deadline; the separate
bounded-shutdown test explicitly requires timeout expiry to release
shutdown. This is a test synchronization issue.

## Implementation details

- Configure Timeout.InfiniteTimeSpan for this flush-ordering scenario so
only the controlled request gates can release disposal. The finite waits
that detect missing send/disposal progress and the finally block that
releases both gates remain in place.
- Use TaskCreationOptions.LongRunning with TaskScheduler.Default for the
blocking Dispose call, leaving thread-pool workers available for
asynchronous sends and assertions.
- Preserve all existing assertions, including waiting for the final send
and checking the second exposure's payload. Production shutdown behavior
and the separate bounded-wait test are unchanged.

## Test coverage

- A package-free .NET 8 harness linked the actual ExposureApi, EVP
transport, cache, exposure models, request factory, and ExposureApiTests
sources. The corrected test method passed 100 consecutive executions,
including its payload assertions. The other test methods also passed:
bounded shutdown, faulted/canceled send loops, and enqueue after
disposal.
- In the same harness, withholding the test's final-send observation
until the deadline reproduced Dispose completing while the final request
remained blocked with both the historical five-second allowance and
current master's one-minute allowance. Gate-controlled shutdown remained
blocked across an observation delay exceeding five seconds and completed
after releasing the final send.
- A negative control that removed Dispose's wait was rejected by the
corrected test's existing final-send assertion.
- This isolated harness uses doubles for external dependencies,
JSON/assertion adapters, and test attributes; it is not a full
repository xUnit run. The focused dotnet test command could not start
because global.json requires SDK 11.0.100-rc.1.26425.128 and only SDK
8.0.412 is installed. Validation on the affected .NET Core 3.0/3.1 CI
jobs remains required.

## Other details
<!-- Fixes #{issue} -->


<!--  ⚠️ Note:

Where possible, please obtain 2 approvals prior to merging. Unless
CODEOWNERS specifies otherwise, for external teams it is typically best
to have one review from a team member, and one review from apm-dotnet.
Trivial changes do not require 2 reviews.

MergeQueue is NOT enabled in this repository. If you have write access
to the repo, the PR has 1-2 approvals (see above), and all of the
required checks have passed, you can use the Squash and Merge button to
merge the PR. If you don't have write access, or you need help, reach
out in the #apm-dotnet channel in Slack.
-->

---

PR by Bits - [View session in
Datadog](https://app.datadoghq.com/code/a2d9735b-f842-47ff-bbc6-6c14a63ead5c)

Comment @DataDog to request changes

Co-authored-by: datadog-bits <263423550+datadog-bits@users.noreply.github.com>
Co-authored-by: btthomas <9452950+btthomas@users.noreply.github.com>
dudikeleti added a commit that referenced this pull request Oct 30, 2026
## Summary of changes

Adds Dynamic Instrumentation rules to the `/sdk-review` lens files, so
the guardrails in `DebuggerSafetyBoundaries.md` are checked before every
push:

- `Security-And-Safety.md`: section 3 is now "Dynamic Instrumentation".
SEC-3.1 also covers expression-tree property access and static property
getters. New rules SEC-3.2 to SEC-3.6 cover runtime-type checks,
dictionary keys and compiler-generated names, values computed from
redacted values, customer data in evaluation errors and logs, and
`Expression.Equal` null checks.
- `Performance.md`: new section 5 with PERF-5.1 and PERF-5.2 for per-hit
locks and cache hits, and failure output on every hit.
- `Correctness.md`: COR-6.4 now says which time bounds are acceptable in
tests, flags raising a timeout to fix a flaky test, and limits queued
markers to single-consumer queues. This replaces #9414.

## Reason for change

The guardrails added to `DebuggerSafetyBoundaries.md` in #9562 are rules
we want enforced, and `/sdk-review` is what runs before every push.
Keeping them in the lens files instead of `AGENTS.md` keeps `AGENTS.md`
small.

Each new Dynamic Instrumentation rule comes from a bug fixed in a recent
PR, and the COR-6.4 change comes from #9414:

| Rule | Fixed in |
| --- | --- |
| SEC-3.1 (update) | #8878 |
| SEC-3.2 runtime type | #9483, #9541, #9547 |
| SEC-3.3 dictionary keys and source names | #9536, #9539, #9548 |
| SEC-3.4 computed from redacted values | #9485, #9537, #9547 |
| SEC-3.5 errors and logs | #9559 |
| SEC-3.6 `Expression.ReferenceEqual` | #9541 |
| PERF-5.1 per-hit locks, cache hits | #9538 |
| PERF-5.2 failure output on every hit | #9536, #9537, #9559 |
| COR-6.4 (update) | from #9414, not a bug fix |

## Implementation details

SEC-3.1 keeps its ID; the section heading changes from "Customer-process
safety" to "Dynamic Instrumentation". The Performance "Don't flag" entry
about uncontended per-request locks now points to PERF-5.1, so the two
don't conflict for locks shared by every thread that hits a probe.

SEC-3.1 still links to `DebuggerSafetyBoundaries.md` for the allowed
execution policy. None of these rules depend on #9562, but #9562 points
the guide's review checklist to them, so merge this PR first.

## Test coverage

Docs only. As in #9472, I ran the rules against commits that introduced
the issues. Each run was one independent lens reviewer reading the
frozen commit and only its lens file. No reviewer was told which rule
was being tested.

| Rule | Commit reviewed | Result |
| --- | --- | --- |
| SEC-3.2 | #8879 | Caught: `ShouldRedactDumpValue(null,
expression.Type)` in `ProbeExpressionParser.Dump.cs` decides redaction
from the declared type |
| SEC-3.4 | #8621 (product code) | Caught: `len(ref password)` and
`eq(ref password, "x")` capture values computed from the redaction
placeholder |
| SEC-3.5 | #8621 (product code) | Caught: capture expression errors
send `e.Message` in `evaluationErrors` |
| SEC-3.6 | #5543 (product code) | Caught: the
`Expression.Equal(expression, Expression.Constant(null))` null check |
| PERF-5.1 | #6292 | Caught: every redaction cache hit takes a
`ReaderWriterLockSlim` read lock and the LFU policy's write lock, and
allocates |
| PERF-5.1 | #9538 | Correctly not flagged (the lock-free fix) |
| PERF-5.2 | #8725 | Missed: the uncapped metric probe path isn't in
that diff |
| PERF-5.2 | #8621 (product code) | Flagged a different per-hit failure
log in the same block (`Evaluation result should not be null`), not the
`Log.Error` in the catch |
| COR-6.4 | #9396 | Caught: the flush timeout raised from 5s to 1 minute
to fix a flaky test |
| COR-6.4 | #9074 | Correctly not flagged (`TaskCompletionSource` with a
30s guard) |

Not tested: SEC-3.1's new expression-tree clause and SEC-3.3. Reviewers
did point out SEC-3.3's literal-only dictionary key check in code that
predates the commits under review.

## Other details

I kept only rules a reviewer can match in a diff and that a PR shows
were needed. An earlier version had a PERF-5.3 rule for
`EvaluationBudget` checks. I dropped it because no PR shows a missed
check, and it mostly explained how the budget works; that guidance stays
in `DebuggerSafetyBoundaries.md` (#9562). SEC-3.3 was also narrowed to
the two shapes a diff shows: dictionary keys checked only when literal,
and keywords matched against compiler-generated names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tests unit tests, integration tests Bits AI type:flake-fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants