Skip to content

[BUG] Fix query obfuscation culture invariant#8850

Merged
dromanol merged 6 commits into
masterfrom
dani/fix-query-obfuscation-culture-invariant
Jun 30, 2026
Merged

[BUG] Fix query obfuscation culture invariant#8850
dromanol merged 6 commits into
masterfrom
dani/fix-query-obfuscation-culture-invariant

Conversation

@dromanol

@dromanol dromanol commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary of changes

Add RegexOptions.CultureInvariant to the query-string obfuscation regex (Obfuscator.cs), plus regression tests covering culture-independent redaction and a ReDoS guard for URL-encoded CJK query strings.

Reason for change

The obfuscation regex was compiled with IgnoreCase but without CultureInvariant, so case-insensitive matching depended on the ambient culture. This caused two problems:

  1. CPU spike on non-ASCII / %-dense query strings (.NET Framework). Without culture invariance, each character comparison uses a culture-aware case-folding path. Investigating a reported production incident (Vault file-download URLs with URL-encoded Korean filenames + auth params), the obfuscation regex consumed ~16 s/min of CPU and pushed system.cpu.user from ~1.6% to ~90%.
    • The cost is strictly linear (verified to 72k chars on both the compiled and interpreted engines) — not catastrophic backtracking. The reported figure is aggregate cost = per-call µs × request rate.
    • At the default DD_HTTP_SERVER_TAG_QUERY_STRING_SIZE=5000, a CJK-encoded query string costs ~1.5–2.3 ms/call on .NET Framework; CultureInvariant cuts that ~2x. (URL-encoding makes the input pure ASCII, but the faster case-folding path still applies.)
  2. Incorrect redaction under Turkic cultures. The dotted/dotless I does not fold to i, so under tr-TR/az-Latn-AZ keywords containing an i (api, public, signature, …) were never redacted, leaking secrets. Reproduces on all runtimes (correctness, not just perf).

Implementation details

One-line change: add RegexOptions.CultureInvariant to the options in Obfuscator. Redaction output is byte-identical for ASCII input; matching is now locale-independent, which is the correct behavior for a security obfuscator.

Explored but rejected: explicit atomic groups (?>…) made it ~2x slower (the cost is the unanchored start-position scan, not internal backtracking). Boundary-anchoring keyword matches is ~2.3x faster but changes redaction semantics (e.g. access_token=<jwt>), so it is out of scope for this fix — see follow-up note below.

Test coverage

  • ObfuscatesIndependentlyOfCurrentCulture (tr-TR / az-Latn-AZ / en-US) — fails before the fix under Turkic cultures, passes after.
  • ObfuscatesNonAsciiValuesWithCustomPatternIndependentlyOfCulture — customer-style custom pattern over Korean secret values.
  • DefaultPatternDoesNotBacktrackOnUrlEncodedCjk (50/500/2000 reps) — ReDoS guard with a tight regex timeout; large CJK payload must complete and still redact a trailing secret.
  • DefaultPatternPassesThroughUnmatchedVaultUrl — documents that the Vault ticket param is not matched by the default pattern.

All existing obfuscator + IAST EvidenceRedactor tests continue to pass.

Other details

The default pattern is a cross-tracer canonical regex; this change keeps its matches identical and only removes culture sensitivity. A separate, behavior-changing proposal (boundary-anchoring to further cut CPU ~2.3x) should be discussed cross-team rather than bundled here. Lowering DD_HTTP_SERVER_TAG_QUERY_STRING_SIZE remains an immediate linear mitigation, stackable with this fix.

dromanol and others added 3 commits June 29, 2026 20:07
The query-string obfuscation regex was compiled with IgnoreCase but
without CultureInvariant. Case-insensitive matching therefore depended
on the ambient culture, which caused two problems:

- CPU spikes when obfuscating non-ASCII query strings on .NET Framework,
  because each character comparison performs culture-aware case folding
  (~2x overall, up to ~4x under tr-TR).
- Incorrect redaction under Turkic cultures: the dotted/dotless 'I' does
  not fold to 'i', so keywords containing 'i' (api, public, signature,
  ...) were never redacted.

Add RegexOptions.CultureInvariant and a regression test asserting
redaction is identical across cultures (tr-TR, az-Latn-AZ, en-US).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Exercises the culture-folding fix through a customer-style custom
obfuscation pattern carrying Korean secret values. Under tr-TR the
upper-case keys containing 'I' (TICKET, EMPID) would otherwise leak
their values unredacted. The pattern is linear (not backtracking);
this guards correctness, not throughput.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Reproduces the reported Vault file-download scenario (URL-encoded
Korean filename + auth params). The default pattern is linear on this
input - URL-encoding makes it pure ASCII and the repetition groups'
alternatives are mutually exclusive - so there is no catastrophic
backtracking. The guard uses a tight regex timeout so any future change
that reintroduces super-linear backtracking would time out and fail.

Also documents that the Vault "ticket" parameter passes through
unredacted by the default pattern.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@dromanol

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6826e2e57d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tracer/test/Datadog.Trace.Tests/Util/Http/QueryStringObfuscatorTests.cs Outdated
@pr-commenter

pr-commenter Bot commented Jun 29, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-06-30 18:13:06

Comparing candidate commit 26f8319 in PR branch dani/fix-query-obfuscation-culture-invariant with baseline commit a068cbf in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 1 performance regressions! Performance is the same for 71 metrics, 0 unstable metrics, 58 known flaky benchmarks, 68 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.HttpClientBenchmark.SendAsync net472

  • 🟥 throughput [-5594.169op/s; -5019.858op/s] or [-6.386%; -5.731%]

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 [-6995.613op/s; -6515.078op/s] or [-8.295%; -7.725%]

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

  • 🟥 throughput [-7138.989op/s; -5815.987op/s] or [-7.259%; -5.914%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 execution_time [+302.421ms; +308.858ms] or [+150.072%; +153.266%]
  • 🟥 throughput [-46.590op/s; -42.895op/s] or [-8.383%; -7.718%]

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

  • 🟥 execution_time [+380.798ms; +382.278ms] or [+300.854%; +302.023%]
  • 🟩 throughput [+90.507op/s; +93.038op/s] or [+11.933%; +12.267%]

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

  • 🟥 execution_time [+394.260ms; +397.242ms] or [+348.905%; +351.544%]

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

  • 🟥 allocated_mem [+1.308KB; +1.308KB] or [+27.528%; +27.540%]

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

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+9.976%; +9.987%]
  • 🟩 execution_time [-16.350ms; -12.166ms] or [-7.636%; -5.682%]
  • 🟩 throughput [+7289.460op/s; +10164.925op/s] or [+5.321%; +7.420%]

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

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+27.500%; +27.510%]

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

  • 🟥 allocated_mem [+1.307KB; +1.307KB] or [+105.743%; +105.758%]
  • 🟥 throughput [-273544.814op/s; -270327.076op/s] or [-27.930%; -27.602%]

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

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+38.557%; +38.566%]
  • 🟩 execution_time [-26.182ms; -21.309ms] or [-11.676%; -9.503%]

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

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+105.288%; +105.304%]
  • 🟥 throughput [-156415.291op/s; -140503.396op/s] or [-22.474%; -20.188%]

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

  • 🟩 throughput [+9182.443op/s; +11822.379op/s] or [+7.315%; +9.418%]

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

  • 🟩 throughput [+455100.723op/s; +476112.656op/s] or [+15.175%; +15.876%]

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

  • 🟩 execution_time [-18.928ms; -14.590ms] or [-8.725%; -6.725%]
  • 🟩 throughput [+137143.042op/s; +191267.649op/s] or [+5.444%; +7.592%]

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

  • 🟥 execution_time [+300.220ms; +300.979ms] or [+150.010%; +150.389%]

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

  • 🟥 execution_time [+299.607ms; +303.989ms] or [+151.093%; +153.302%]

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

  • 🟥 execution_time [+300.521ms; +303.604ms] or [+151.379%; +152.932%]

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

  • 🟥 execution_time [+296.433ms; +297.810ms] or [+145.596%; +146.272%]

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

  • 🟥 execution_time [+296.868ms; +298.760ms] or [+145.128%; +146.053%]

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

  • 🟥 execution_time [+304.513ms; +307.453ms] or [+152.195%; +153.665%]

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

  • 🟥 execution_time [+21.690µs; +47.559µs] or [+6.925%; +15.183%]
  • 🟥 throughput [-431.014op/s; -222.291op/s] or [-13.436%; -6.929%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+299.160ms; +299.882ms] or [+149.312%; +149.672%]

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

  • 🟥 execution_time [+411.431ms; +418.054ms] or [+447.037%; +454.233%]
  • 🟩 throughput [+1094.188op/s; +1300.872op/s] or [+8.991%; +10.689%]

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

  • unstable execution_time [+249.420ms; +310.400ms] or [+189.382%; +235.684%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • unstable execution_time [+265.628ms; +320.444ms] or [+122.133%; +147.337%]
  • 🟥 throughput [-565.787op/s; -509.874op/s] or [-51.266%; -46.200%]

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

  • unstable execution_time [+200.724ms; +334.022ms] or [+85.540%; +142.346%]
  • 🟥 throughput [-674.301op/s; -590.547op/s] or [-44.976%; -39.390%]

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

  • 🟥 execution_time [+330.624ms; +339.383ms] or [+197.752%; +202.990%]
  • 🟥 throughput [-460.394op/s; -422.648op/s] or [-32.057%; -29.428%]

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

  • 🟩 throughput [+47.167op/s; +61.540op/s] or [+5.086%; +6.635%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 execution_time [+302.651ms; +304.913ms] or [+152.409%; +153.548%]

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

  • 🟥 execution_time [+302.742ms; +313.504ms] or [+151.704%; +157.097%]

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

  • 🟥 execution_time [+300.799ms; +304.594ms] or [+151.109%; +153.015%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 execution_time [+302.494ms; +304.142ms] or [+151.902%; +152.730%]
  • 🟩 throughput [+18542.128op/s; +20149.950op/s] or [+6.212%; +6.751%]

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

  • 🟥 execution_time [+298.418ms; +300.857ms] or [+147.554%; +148.760%]

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

  • 🟥 execution_time [+302.915ms; +306.489ms] or [+153.530%; +155.342%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 execution_time [+301.085ms; +303.374ms] or [+151.118%; +152.266%]

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

  • 🟥 execution_time [+300.914ms; +303.810ms] or [+149.978%; +151.422%]
  • 🟩 throughput [+40954.430op/s; +49694.070op/s] or [+8.132%; +9.868%]

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

  • 🟥 execution_time [+300.545ms; +304.240ms] or [+149.519%; +151.357%]

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

  • 🟩 execution_time [-16.886ms; -13.210ms] or [-7.852%; -6.143%]
  • 🟩 throughput [+20189.072op/s; +28190.866op/s] or [+5.538%; +7.734%]

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

  • unstable execution_time [+10.207µs; +52.667µs] or [+2.521%; +13.009%]

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

  • 🟩 allocated_mem [-25.870KB; -25.847KB] or [-9.437%; -9.429%]
  • unstable execution_time [-42.476µs; +17.815µs] or [-8.395%; +3.521%]
  • unstable throughput [-51.291op/s; +159.713op/s] or [-2.559%; +7.970%]

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

  • 🟩 allocated_mem [-25.252KB; -25.233KB] or [-9.206%; -9.199%]
  • unstable execution_time [-48.323µs; +15.890µs] or [-8.374%; +2.754%]
  • unstable throughput [-31.525op/s; +145.727op/s] or [-1.801%; +8.326%]

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

  • unstable execution_time [+6.042µs; +10.757µs] or [+14.281%; +25.426%]
  • 🟥 throughput [-4783.240op/s; -2883.896op/s] or [-20.136%; -12.140%]

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

  • unstable execution_time [-13.154µs; -4.880µs] or [-20.408%; -7.571%]
  • unstable throughput [+1211.209op/s; +3016.561op/s] or [+7.431%; +18.508%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+299.990ms; +302.018ms] or [+151.631%; +152.656%]

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

  • 🟥 execution_time [+301.772ms; +304.841ms] or [+153.601%; +155.163%]

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

  • 🟥 execution_time [+299.517ms; +302.099ms] or [+149.945%; +151.238%]

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

  • 🟩 throughput [+28425.824op/s; +32230.412op/s] or [+5.380%; +6.101%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+300.912ms; +303.187ms] or [+149.978%; +151.111%]

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

  • 🟥 execution_time [+298.350ms; +313.744ms] or [+149.817%; +157.547%]

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

  • 🟥 execution_time [+303.487ms; +305.717ms] or [+153.909%; +155.040%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+299.567ms; +300.484ms] or [+149.426%; +149.883%]
  • 🟩 throughput [+61197467.278op/s; +61533329.076op/s] or [+44.568%; +44.812%]

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

  • unstable execution_time [+343.253ms; +396.970ms] or [+426.896%; +493.702%]

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

  • 🟥 execution_time [+298.841ms; +299.921ms] or [+149.055%; +149.594%]

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

  • 🟩 throughput [+87992.313op/s; +95555.004op/s] or [+8.216%; +8.922%]

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

  • 🟩 throughput [+45497.845op/s; +64643.367op/s] or [+5.266%; +7.482%]

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

  • 🟩 throughput [+75066.488op/s; +82869.802op/s] or [+7.455%; +8.230%]

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

  • 🟩 throughput [+49197.951op/s; +55666.142op/s] or [+8.933%; +10.108%]

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

  • 🟩 throughput [+82410.147op/s; +99199.930op/s] or [+9.207%; +11.083%]

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.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net6.0
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net6.0
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark netcoreapp3.1
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack netcoreapp3.1
  • 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 netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net472
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog netcoreapp3.1
  • scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive netcoreapp3.1
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net6.0
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes netcoreapp3.1
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

@dd-trace-dotnet-ci-bot

dd-trace-dotnet-ci-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

Execution-Time Benchmarks Report ⏱️

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

✅ No regressions detected - check the details below

Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration69.73 ± (69.71 - 70.00) ms73.24 ± (72.96 - 73.37) ms+5.0%✅⬆️
.NET Framework 4.8 - Bailout
duration75.72 ± (75.76 - 76.25) ms76.44 ± (76.40 - 76.87) ms+1.0%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1077.56 ± (1077.13 - 1083.49) ms1079.69 ± (1081.57 - 1089.66) ms+0.2%✅⬆️
.NET Core 3.1 - Baseline
process.internal_duration_ms22.05 ± (22.01 - 22.08) ms22.38 ± (22.33 - 22.44) ms+1.5%✅⬆️
process.time_to_main_ms80.49 ± (80.33 - 80.66) ms83.48 ± (83.19 - 83.78) ms+3.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.91 ± (10.91 - 10.91) MB10.92 ± (10.92 - 10.93) MB+0.1%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms22.37 ± (22.32 - 22.42) ms22.00 ± (21.97 - 22.03) ms-1.6%
process.time_to_main_ms84.90 ± (84.59 - 85.22) ms82.28 ± (82.11 - 82.45) ms-3.1%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.96 ± (10.95 - 10.96) MB10.96 ± (10.96 - 10.96) MB+0.0%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms211.35 ± (210.35 - 212.34) ms211.75 ± (210.91 - 212.58) ms+0.2%✅⬆️
process.time_to_main_ms527.71 ± (526.59 - 528.83) ms531.31 ± (530.17 - 532.45) ms+0.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.73 ± (48.68 - 48.77) MB48.74 ± (48.71 - 48.77) MB+0.0%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.1%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms20.92 ± (20.89 - 20.95) ms21.23 ± (21.18 - 21.27) ms+1.5%✅⬆️
process.time_to_main_ms69.89 ± (69.75 - 70.03) ms72.12 ± (71.86 - 72.39) ms+3.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.63 ± (10.63 - 10.63) MB10.63 ± (10.63 - 10.64) MB+0.0%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms20.89 ± (20.86 - 20.92) ms21.00 ± (20.97 - 21.03) ms+0.6%✅⬆️
process.time_to_main_ms70.97 ± (70.87 - 71.06) ms71.83 ± (71.66 - 72.00) ms+1.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.75 ± (10.74 - 10.75) MB10.76 ± (10.75 - 10.76) MB+0.1%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms371.08 ± (368.77 - 373.40) ms372.18 ± (369.96 - 374.40) ms+0.3%✅⬆️
process.time_to_main_ms537.02 ± (535.81 - 538.24) ms537.29 ± (536.17 - 538.42) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed50.14 ± (50.12 - 50.17) MB50.18 ± (50.15 - 50.20) MB+0.1%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.0%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms19.34 ± (19.29 - 19.38) ms19.16 ± (19.13 - 19.19) ms-0.9%
process.time_to_main_ms71.59 ± (71.37 - 71.81) ms68.88 ± (68.77 - 68.99) ms-3.8%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.68 ± (7.67 - 7.68) MB7.66 ± (7.65 - 7.66) MB-0.2%
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms19.07 ± (19.05 - 19.10) ms19.34 ± (19.31 - 19.38) ms+1.4%✅⬆️
process.time_to_main_ms70.81 ± (70.66 - 70.97) ms72.02 ± (71.77 - 72.26) ms+1.7%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.73 ± (7.72 - 7.73) MB7.72 ± (7.71 - 7.72) MB-0.1%
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms297.51 ± (295.67 - 299.34) ms297.92 ± (295.68 - 300.16) ms+0.1%✅⬆️
process.time_to_main_ms484.57 ± (483.67 - 485.48) ms485.08 ± (484.08 - 486.08) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed37.12 ± (37.09 - 37.15) MB37.18 ± (37.15 - 37.21) MB+0.2%✅⬆️
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)+0.0%✅⬆️

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration211.30 ± (210.96 - 211.92) ms205.09 ± (204.90 - 205.62) ms-2.9%
.NET Framework 4.8 - Bailout
duration218.27 ± (218.05 - 219.28) ms208.03 ± (207.61 - 208.43) ms-4.7%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1241.74 ± (1242.04 - 1250.05) ms1215.80 ± (1214.37 - 1220.41) ms-2.1%
.NET Core 3.1 - Baseline
process.internal_duration_ms205.93 ± (205.38 - 206.47) ms197.98 ± (197.55 - 198.42) ms-3.9%
process.time_to_main_ms89.23 ± (88.96 - 89.49) ms86.90 ± (86.65 - 87.15) ms-2.6%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed15.98 ± (15.97 - 16.00) MB16.00 ± (15.98 - 16.02) MB+0.1%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-1.1%
.NET Core 3.1 - Bailout
process.internal_duration_ms203.84 ± (203.28 - 204.41) ms198.88 ± (198.57 - 199.20) ms-2.4%
process.time_to_main_ms89.81 ± (89.57 - 90.04) ms88.63 ± (88.38 - 88.88) ms-1.3%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.02 ± (16.00 - 16.03) MB16.08 ± (16.05 - 16.11) MB+0.4%✅⬆️
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (20 - 21)-1.6%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms395.88 ± (394.51 - 397.24) ms391.18 ± (389.55 - 392.80) ms-1.2%
process.time_to_main_ms554.14 ± (552.79 - 555.50) ms545.84 ± (544.63 - 547.05) ms-1.5%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed59.10 ± (58.95 - 59.25) MB58.29 ± (58.06 - 58.52) MB-1.4%
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)-0.6%
.NET 6 - Baseline
process.internal_duration_ms205.00 ± (204.46 - 205.54) ms204.09 ± (203.65 - 204.54) ms-0.4%
process.time_to_main_ms75.72 ± (75.43 - 76.00) ms75.85 ± (75.56 - 76.13) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.33 ± (16.31 - 16.35) MB16.35 ± (16.32 - 16.38) MB+0.1%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 20)+1.6%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms205.19 ± (204.70 - 205.67) ms202.69 ± (202.23 - 203.14) ms-1.2%
process.time_to_main_ms76.85 ± (76.62 - 77.08) ms76.55 ± (76.34 - 76.76) ms-0.4%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.39 ± (16.37 - 16.41) MB16.38 ± (16.36 - 16.40) MB-0.1%
runtime.dotnet.threads.count21 ± (20 - 21)20 ± (20 - 20)-0.8%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms584.24 ± (582.08 - 586.40) ms581.76 ± (579.29 - 584.24) ms-0.4%
process.time_to_main_ms560.50 ± (559.25 - 561.76) ms558.37 ± (557.24 - 559.50) ms-0.4%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed61.39 ± (61.29 - 61.49) MB61.26 ± (61.20 - 61.33) MB-0.2%
runtime.dotnet.threads.count31 ± (31 - 31)31 ± (31 - 31)-0.4%
.NET 8 - Baseline
process.internal_duration_ms203.53 ± (203.00 - 204.07) ms200.29 ± (199.83 - 200.76) ms-1.6%
process.time_to_main_ms75.20 ± (74.95 - 75.44) ms74.23 ± (73.97 - 74.49) ms-1.3%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.72 ± (11.70 - 11.73) MB11.69 ± (11.67 - 11.71) MB-0.2%
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.2%✅⬆️
.NET 8 - Bailout
process.internal_duration_ms202.69 ± (202.21 - 203.17) ms200.12 ± (199.77 - 200.47) ms-1.3%
process.time_to_main_ms76.14 ± (75.91 - 76.38) ms75.24 ± (75.03 - 75.45) ms-1.2%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.75 ± (11.73 - 11.77) MB11.73 ± (11.71 - 11.75) MB-0.2%
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (19 - 20)-0.6%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms514.06 ± (510.58 - 517.54) ms513.64 ± (510.39 - 516.89) ms-0.1%
process.time_to_main_ms510.74 ± (509.78 - 511.71) ms508.12 ± (507.11 - 509.13) ms-0.5%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed50.91 ± (50.86 - 50.97) MB50.99 ± (50.95 - 51.04) MB+0.2%✅⬆️
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)+0.2%✅⬆️
Comparison explanation

Execution-time benchmarks measure the whole time it takes to execute a program, and are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are highlighted in **red**. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

Duration charts
FakeDbCommand (.NET Framework 4.8)
gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8850) - mean (73ms)  : 70, 76
    master - mean (70ms)  : 68, 72

    section Bailout
    This PR (8850) - mean (77ms)  : 73, 80
    master - mean (76ms)  : 72, 80

    section CallTarget+Inlining+NGEN
    This PR (8850) - mean (1,086ms)  : 1025, 1146
    master - mean (1,080ms)  : 1034, 1126

Loading
FakeDbCommand (.NET Core 3.1)
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8850) - mean (113ms)  : 107, 119
    master - mean (109ms)  : 106, 112

    section Bailout
    This PR (8850) - mean (111ms)  : 107, 115
    master - mean (115ms)  : 109, 121

    section CallTarget+Inlining+NGEN
    This PR (8850) - mean (780ms)  : 755, 804
    master - mean (777ms)  : 759, 795

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8850) - mean (100ms)  : 94, 106
    master - mean (97ms)  : 94, 99

    section Bailout
    This PR (8850) - mean (99ms)  : 96, 103
    master - mean (98ms)  : 97, 99

    section CallTarget+Inlining+NGEN
    This PR (8850) - mean (940ms)  : 892, 988
    master - mean (938ms)  : 896, 979

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8850) - mean (94ms)  : 92, 97
    master - mean (99ms)  : 94, 103

    section Bailout
    This PR (8850) - mean (99ms)  : 93, 105
    master - mean (97ms)  : 94, 100

    section CallTarget+Inlining+NGEN
    This PR (8850) - mean (814ms)  : 778, 849
    master - mean (812ms)  : 779, 844

Loading
HttpMessageHandler (.NET Framework 4.8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8850) - mean (205ms)  : 201, 209
    master - mean (211ms)  : 205, 218

    section Bailout
    This PR (8850) - mean (208ms)  : 204, 212
    master - mean (219ms)  : 209, 228

    section CallTarget+Inlining+NGEN
    This PR (8850) - mean (1,217ms)  : 1173, 1262
    master - mean (1,246ms)  : 1185, 1307

Loading
HttpMessageHandler (.NET Core 3.1)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8850) - mean (295ms)  : 288, 302
    master - mean (306ms)  : 293, 320

    section Bailout
    This PR (8850) - mean (298ms)  : 293, 303
    master - mean (304ms)  : 293, 314

    section CallTarget+Inlining+NGEN
    This PR (8850) - mean (980ms)  : 962, 999
    master - mean (994ms)  : 961, 1027

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8850) - mean (290ms)  : 284, 295
    master - mean (290ms)  : 280, 300

    section Bailout
    This PR (8850) - mean (289ms)  : 284, 294
    master - mean (291ms)  : 284, 299

    section CallTarget+Inlining+NGEN
    This PR (8850) - mean (1,173ms)  : 1132, 1213
    master - mean (1,183ms)  : 1150, 1216

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8850) - mean (285ms)  : 277, 293
    master - mean (289ms)  : 282, 296

    section Bailout
    This PR (8850) - mean (286ms)  : 281, 291
    master - mean (290ms)  : 284, 296

    section CallTarget+Inlining+NGEN
    This PR (8850) - mean (1,054ms)  : 1006, 1103
    master - mean (1,061ms)  : 1002, 1120

Loading

The new default-pattern tests construct the default obfuscation regex,
which is documented to crash the RegexRunner on netcoreapp2.1/Linux/ARM64.
Switch them to Skippable + SkipOn, matching ObfuscateWithDefaultPattern,
so that target is skipped rather than failing the suite. The
custom-pattern test does not use the default regex and is left as-is.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@dromanol
dromanol marked this pull request as ready for review June 30, 2026 08:27
@dromanol
dromanol requested a review from a team as a code owner June 30, 2026 08:27
@andrewlock andrewlock added type:performance Performance, speed, latency, resource usage (CPU, memory) identified-by:customer and removed type:bug labels Jun 30, 2026

@andrewlock andrewlock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, though I would add some extra unicode tests, and remove the timeout-related one (which will flake in CI)

Comment on lines +161 to +196
// Regression guard for a reported production CPU spike on Vault file-download URLs carrying
// URL-encoded CJK filenames alongside auth-related parameters. URL-encoding makes the input pure
// ASCII ("%EC%84%A4..."), and the default pattern's repetition groups are linear (their
// alternatives are mutually exclusive by the second character), so this must NOT exhibit
// catastrophic backtracking. A deliberately tight timeout means any future change that
// reintroduces super-linear backtracking would time out (Obfuscate returns string.Empty) and
// fail the trailing-secret assertion below.
[SkippableTheory]
[InlineData(50)]
[InlineData(500)]
[InlineData(2000)]
public void DefaultPatternDoesNotBacktrackOnUrlEncodedCjk(int filenameRepetitions)
{
// the default regex seems to crash the regex engine on netcoreapp2.1 under arm64, with a null reference exception on the dotnet RegexRunner. Its ok as these arent supported in auto instrumentation, we just warn not to reuse this regex if 2.1&arm64 is the environment
#if NETCOREAPP2_1
SkipOn.PlatformAndArchitecture(SkipOn.PlatformValue.Linux, SkipOn.ArchitectureValue.ARM64);
#endif
const double tightTimeoutMs = 2000;
var encodedCjkFilename = string.Concat(Enumerable.Repeat("%EC%84%A4%EA%B3%84%EC%9E%90%EB%A3%8C", filenameRepetitions));
// Mirrors the reported URL shape, with a genuinely redactable secret appended so a successful
// (non-timed-out) run is observable in the output.
var queryString = $"/Vault/vaultserver.aspx?fileName={encodedCjkFilename}_.xlsx&vaultId=67BBB9204FE84A8981ED8313049BA06C&password=hunter2";

var logger = new Mock<IDatadogLogger>();
var queryStringObfuscator = ObfuscatorFactory.GetObfuscator(tightTimeoutMs, TracerSettingsConstants.DefaultObfuscationQueryStringRegex, logger.Object);

var result = queryStringObfuscator.Obfuscate(queryString);

// Completed within the timeout (no RegexMatchTimeoutException, which would yield string.Empty)
// and still redacted the trailing secret while leaving the encoded CJK bytes untouched.
result.Should().Be($"/Vault/vaultserver.aspx?fileName={encodedCjkFilename}_.xlsx&vaultId=67BBB9204FE84A8981ED8313049BA06C&<redacted>");
}

// The reported Vault "ticket" parameter is not actually matched by the default pattern (there is
// no "ticket" keyword and the value does not satisfy any keyword suffix), so the URL passes
// through unchanged - and, crucially, quickly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test is absolutely asking for flake in CI - I would remove it

Suggested change
// Regression guard for a reported production CPU spike on Vault file-download URLs carrying
// URL-encoded CJK filenames alongside auth-related parameters. URL-encoding makes the input pure
// ASCII ("%EC%84%A4..."), and the default pattern's repetition groups are linear (their
// alternatives are mutually exclusive by the second character), so this must NOT exhibit
// catastrophic backtracking. A deliberately tight timeout means any future change that
// reintroduces super-linear backtracking would time out (Obfuscate returns string.Empty) and
// fail the trailing-secret assertion below.
[SkippableTheory]
[InlineData(50)]
[InlineData(500)]
[InlineData(2000)]
public void DefaultPatternDoesNotBacktrackOnUrlEncodedCjk(int filenameRepetitions)
{
// the default regex seems to crash the regex engine on netcoreapp2.1 under arm64, with a null reference exception on the dotnet RegexRunner. Its ok as these arent supported in auto instrumentation, we just warn not to reuse this regex if 2.1&arm64 is the environment
#if NETCOREAPP2_1
SkipOn.PlatformAndArchitecture(SkipOn.PlatformValue.Linux, SkipOn.ArchitectureValue.ARM64);
#endif
const double tightTimeoutMs = 2000;
var encodedCjkFilename = string.Concat(Enumerable.Repeat("%EC%84%A4%EA%B3%84%EC%9E%90%EB%A3%8C", filenameRepetitions));
// Mirrors the reported URL shape, with a genuinely redactable secret appended so a successful
// (non-timed-out) run is observable in the output.
var queryString = $"/Vault/vaultserver.aspx?fileName={encodedCjkFilename}_.xlsx&vaultId=67BBB9204FE84A8981ED8313049BA06C&password=hunter2";
var logger = new Mock<IDatadogLogger>();
var queryStringObfuscator = ObfuscatorFactory.GetObfuscator(tightTimeoutMs, TracerSettingsConstants.DefaultObfuscationQueryStringRegex, logger.Object);
var result = queryStringObfuscator.Obfuscate(queryString);
// Completed within the timeout (no RegexMatchTimeoutException, which would yield string.Empty)
// and still redacted the trailing secret while leaving the encoded CJK bytes untouched.
result.Should().Be($"/Vault/vaultserver.aspx?fileName={encodedCjkFilename}_.xlsx&vaultId=67BBB9204FE84A8981ED8313049BA06C&<redacted>");
}
// The reported Vault "ticket" parameter is not actually matched by the default pattern (there is
// no "ticket" keyword and the value does not satisfy any keyword suffix), so the URL passes
// through unchanged - and, crucially, quickly.

@NachoEchevarria NachoEchevarria left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you!

dromanol and others added 2 commits June 30, 2026 17:06
The timeout-based ReDoS guard relied on a tight regex timeout and could
flake under CI load. Replace it with RedactsSecretsWhilePreservingUnicodeValues,
which deterministically checks that a secret is redacted while surrounding
multi-byte values (CJK, RTL Arabic, surrogate-pair emoji, accents, Cyrillic)
are left byte-for-byte intact.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@dromanol
dromanol merged commit 2ae2dcb into master Jun 30, 2026
140 checks passed
@dromanol
dromanol deleted the dani/fix-query-obfuscation-culture-invariant branch June 30, 2026 18:50
@github-actions github-actions Bot added this to the vNext-v3 milestone Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:asm identified-by:customer type:performance Performance, speed, latency, resource usage (CPU, memory)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants