Skip to content

Implement normalised http routes - #4101

Open
estringana wants to merge 27 commits into
masterfrom
estringana/normalise-http-route
Open

Implement normalised http routes#4101
estringana wants to merge 27 commits into
masterfrom
estringana/normalise-http-route

Conversation

@estringana

@estringana estringana commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Description

Add _dd.appsec.normalized_route tag to HTTP framework integrations (Laravel, Slim, Symfony, Laminas, CakePHP, Yii, CodeIgniter, WordPress) per RFC-1103. The tag exposes a normalized form of the matched route, stripping concrete parameter values and framework-specific syntax (regexconstraints, optional markers) into a canonical {param} notation suitable for security analysis.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Snapshots difference summary

The following differences have been observed in committed snapshots. It is meant to help the reviewer.
The diff is simplistic, so please check some files anyway while we improve it.

If you need to update snapshots, please refer to CONTRIBUTING.md

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Aug 10, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

🚦 10 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | min install tests — 🔧 Needs a code fix, caused by this PR

View in Datadog · View in GitLab

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [8.3] — 🔧 Needs a code fix, caused by this PR

View in Datadog · View in GitLab

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [8.5] — 🔧 Needs a code fix, caused by this PR

View in Datadog · View in GitLab

View all 10 failed jobs.

❄️ 68 New flaky tests detected

testCakePHPCatchAll from unit.DDTrace\Tests\Unit\Util\Normalizer\RouteNormalizerTest   View in Datadog
DDTrace
Exception: add DDTrace to bridge/_files.php or bridge/dd_register_optional_deps_autoloader.php

tests/bootstrap_common.php:47
tests/Unit/Util/Normalizer/RouteNormalizerTest.php:319
phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:52
testCakePHPMixedSegment from unit.DDTrace\Tests\Unit\Util\Normalizer\RouteNormalizerTest   View in Datadog
DDTrace
Exception: add DDTrace to bridge/_files.php or bridge/dd_register_optional_deps_autoloader.php

tests/bootstrap_common.php:47
tests/Unit/Util/Normalizer/RouteNormalizerTest.php:313
phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:52

View in Flaky Test Management

ℹ️ Info

No other issues found (see more)

🧪 All tests passed

🔄 Datadog auto-retried 1 job - 1 passed on retry View in Datadog

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.63% (+0.00%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 34e4e8b | Docs | View more details | Give us feedback!

@estringana
estringana force-pushed the estringana/normalise-http-route branch 3 times, most recently from 0cc69dd to 1fa5485 Compare August 14, 2026 10:19
@pr-commenter

pr-commenter Bot commented Aug 14, 2026

Copy link
Copy Markdown

Benchmarks [ tracer ]

Benchmark execution time: 2026-08-18 17:18:59

Comparing candidate commit 2ab71bd in PR branch estringana/normalise-http-route with baseline commit d97b51c in branch master.

Found 4 performance improvements and 37 performance regressions! Performance is the same for 151 metrics, 2 unstable metrics.

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:ComposerTelemetryBench/benchTelemetryParsing

  • 🟥 mem_peak [+137.616KB; +137.616KB] or [+3.390%; +3.390%]

scenario:ContextPropagationBench/benchExtractHeaders128Bit

  • 🟥 mem_peak [+138.160KB; +138.160KB] or [+3.403%; +3.403%]

scenario:ContextPropagationBench/benchExtractHeaders128Bit-opcache

  • 🟩 execution_time [-855.572ns; -801.761ns] or [-50.666%; -47.479%]

scenario:ContextPropagationBench/benchExtractHeaders64Bit

  • 🟥 mem_peak [+138.160KB; +138.160KB] or [+3.403%; +3.403%]

scenario:ContextPropagationBench/benchExtractTraceContext128Bit

  • 🟥 mem_peak [+138.160KB; +138.160KB] or [+3.403%; +3.403%]

scenario:ContextPropagationBench/benchExtractTraceContext64Bit

  • 🟥 mem_peak [+138.160KB; +138.160KB] or [+3.403%; +3.403%]

scenario:ContextPropagationBench/benchInject128Bit

  • 🟥 mem_peak [+138.168KB; +138.168KB] or [+3.403%; +3.403%]

scenario:ContextPropagationBench/benchInject128Bit-opcache

  • 🟩 execution_time [-852.889ns; -757.111ns] or [-34.061%; -30.236%]

scenario:ContextPropagationBench/benchInject64Bit

  • 🟥 mem_peak [+138.168KB; +138.168KB] or [+3.403%; +3.403%]

scenario:EmptyFileBench/benchEmptyFileBaseline

  • 🟥 mem_peak [+146.128KB; +146.128KB] or [+2.784%; +2.784%]

scenario:EmptyFileBench/benchEmptyFileDdprof

  • 🟥 mem_peak [+145.533KB; +147.706KB] or [+2.769%; +2.810%]

scenario:EmptyFileBench/benchEmptyFileOverhead

  • 🟥 mem_peak [+146.128KB; +146.128KB] or [+2.784%; +2.784%]

scenario:HookBench/benchHookOverheadInstallHookOnFunction

  • 🟥 mem_peak [+138.032KB; +138.032KB] or [+3.399%; +3.399%]

scenario:HookBench/benchHookOverheadInstallHookOnMethod

  • 🟥 mem_peak [+138.032KB; +138.032KB] or [+3.399%; +3.399%]

scenario:HookBench/benchHookOverheadTraceFunction

  • 🟥 mem_peak [+146.784KB; +146.784KB] or [+3.257%; +3.257%]

scenario:HookBench/benchHookOverheadTraceMethod

  • 🟥 mem_peak [+146.784KB; +146.788KB] or [+3.211%; +3.211%]

scenario:HookBench/benchWithoutHook

  • 🟥 mem_peak [+138.048KB; +138.048KB] or [+3.400%; +3.400%]

scenario:LaravelBench/benchLaravelBaseline

  • 🟥 mem_peak [+146.160KB; +146.160KB] or [+2.784%; +2.784%]

scenario:LaravelBench/benchLaravelDdprof

  • 🟥 mem_peak [+142.415KB; +147.421KB] or [+2.708%; +2.803%]

scenario:LaravelBench/benchLaravelOverhead

  • 🟥 mem_peak [+146.160KB; +146.160KB] or [+2.784%; +2.784%]

scenario:LogsInjectionBench/benchLogsInfoBaseline-opcache

  • 🟥 execution_time [+121.955ns; +166.845ns] or [+7.661%; +10.481%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟥 mem_peak [+146.784KB; +146.784KB] or [+3.399%; +3.399%]
  • 🟩 execution_time [-6.920µs; -3.540µs] or [-6.109%; -3.125%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache

  • 🟩 execution_time [-8.971µs; -7.809µs] or [-8.059%; -7.015%]

scenario:PDOBench/benchPDOBaseline

  • 🟥 mem_peak [+146.784KB; +146.784KB] or [+3.583%; +3.583%]

scenario:PHPRedisBench/benchRedisBaseline

  • 🟥 mem_peak [+137.616KB; +137.616KB] or [+3.389%; +3.389%]

scenario:SamplingRuleMatchingBench/benchGlobMatching1

  • 🟥 mem_peak [+141.288KB; +141.288KB] or [+3.480%; +3.480%]

scenario:SamplingRuleMatchingBench/benchGlobMatching2

  • 🟥 mem_peak [+141.288KB; +141.288KB] or [+3.480%; +3.480%]

scenario:SamplingRuleMatchingBench/benchGlobMatching3

  • 🟥 mem_peak [+141.288KB; +141.288KB] or [+3.480%; +3.480%]

scenario:SamplingRuleMatchingBench/benchGlobMatching4

  • 🟥 mem_peak [+141.288KB; +141.288KB] or [+3.480%; +3.480%]

scenario:SamplingRuleMatchingBench/benchRegexMatching1

  • 🟥 mem_peak [+141.288KB; +141.288KB] or [+3.480%; +3.480%]

scenario:SamplingRuleMatchingBench/benchRegexMatching2

  • 🟥 mem_peak [+141.288KB; +141.288KB] or [+3.480%; +3.480%]

scenario:SamplingRuleMatchingBench/benchRegexMatching3

  • 🟥 mem_peak [+141.288KB; +141.288KB] or [+3.480%; +3.480%]

scenario:SamplingRuleMatchingBench/benchRegexMatching4

  • 🟥 mem_peak [+141.288KB; +141.288KB] or [+3.480%; +3.480%]

scenario:SpanBench/benchDatadogAPI

  • 🟥 mem_peak [+139.520KB; +139.520KB] or [+3.437%; +3.437%]

scenario:SymfonyBench/benchSymfonyBaseline

  • 🟥 mem_peak [+146.104KB; +146.193KB] or [+2.783%; +2.784%]

scenario:SymfonyBench/benchSymfonyDdprof

  • 🟥 mem_peak [+122.231KB; +145.766KB] or [+2.303%; +2.747%]

scenario:SymfonyBench/benchSymfonyOverhead

  • 🟥 mem_peak [+146.160KB; +146.160KB] or [+2.784%; +2.784%]

scenario:TraceAnnotationsBench/benchTraceAnnotationOverhead

  • 🟥 mem_peak [+146.782KB; +146.787KB] or [+3.206%; +3.206%]

scenario:TraceFlushBench/benchFlushTrace

  • 🟥 mem_peak [+146.784KB; +146.784KB] or [+3.544%; +3.544%]

scenario:TraceSerializationBench/benchSerializeTrace

  • 🟥 mem_peak [+146.784KB; +146.784KB] or [+3.464%; +3.464%]

@estringana
estringana force-pushed the estringana/normalise-http-route branch from a2be41b to 7b7f971 Compare August 14, 2026 12:53
@estringana
estringana marked this pull request as ready for review August 14, 2026 14:55
@estringana
estringana requested review from a team as code owners August 14, 2026 14:55
@estringana
estringana requested review from tabgok and removed request for a team August 14, 2026 14:55

@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: 7b7f9710a5

ℹ️ 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 src/DDTrace/Util/RouteNormalizer.php
Comment thread src/DDTrace/Integrations/Slim/SlimIntegration.php Outdated
Comment thread src/DDTrace/Integrations/WordPress/WordPressIntegrationLoader.php Outdated
Comment thread src/DDTrace/Integrations/CodeIgniter/V2/CodeIgniterIntegration.php Outdated
Comment thread src/DDTrace/Util/RouteNormalizer.php Outdated
Comment thread src/DDTrace/Util/RouteNormalizer.php Outdated
Comment thread src/DDTrace/Util/RouteNormalizer.php Outdated
Comment thread src/DDTrace/Integrations/Symfony/SymfonyIntegration.php Outdated
Comment thread src/DDTrace/Util/RouteNormalizer.php
Comment thread src/DDTrace/Util/RouteNormalizer.php
@bwoebi

bwoebi commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Do you have a rough estimate on the overhead of the route normalization? It seems expensive.

Laminas is obviously just slow because it does runtime route matching, but other stacks like Slim or Symfony rely on precompiled routes.
E.g. for Symfony we could make it part of the logic used in #3676. Please check if other frameworks have similar, acceptable solutions. Or consider some caching in the C code. (a LRU cache of route to normalized route with e.g. 500 routes max)

@estringana
estringana force-pushed the estringana/normalise-http-route branch from ff7f8fe to 8632abe Compare August 18, 2026 10:21
@tabgok

tabgok commented Aug 18, 2026

Copy link
Copy Markdown

Approving from the stance of IDM, due to the new field being introduced

estringana and others added 12 commits August 18, 2026 17:55
Add missing Tag::APPSEC_NORMALIZED_ROUTE assertions to:
- Symfony TraceSearchConfigTest (V4_4, V5_0, V5_1, V5_2, V6_2)
- Laravel TraceSearchConfigTest (V4, V5_7, V5_8, V8_x)
- Laravel V8_x RouteCachingTest and InternalExceptionsTest
- Laravel Octane CommonScenariosTest
- Yii ParameterizedRouteTest, ModuleTest, LazyLoadingIntegrationsFromYiiTest
- CodeIgniter ExitTest and NoCI_ControllertTest
- Fix UserAvailableConstantsTest tag ordering (APPSEC_NORMALIZED_ROUTE
  must appear after HTTP_ROUTE to match Tag.php declaration order)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@estringana
estringana force-pushed the estringana/normalise-http-route branch from b57a9e9 to 2ab71bd Compare August 18, 2026 15:55
Comment thread tracer/routing_cache.c Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants