Skip to content

Add http.route tag to SymfonyIntegration.php #2992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 6, 2025
Merged

Conversation

cataphract
Copy link
Contributor

Description

Adds http.route to symfony. Supersedes #2710 and #2477

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@cataphract cataphract requested review from a team as code owners December 12, 2024 02:26
@cataphract cataphract force-pushed the glopes/symfony-route branch 4 times, most recently from 6a1adeb to b32dca7 Compare December 12, 2024 02:52
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.93%. Comparing base (38ce35a) to head (6df661a).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2992      +/-   ##
==========================================
- Coverage   61.96%   61.93%   -0.03%     
==========================================
  Files         140      140              
  Lines       12388    12388              
  Branches     1622     1622              
==========================================
- Hits         7676     7673       -3     
- Misses       3999     4002       +3     
  Partials      713      713              

see 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 38ce35a...6df661a. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pr-commenter
Copy link

pr-commenter bot commented Dec 12, 2024

Benchmarks [ tracer ]

Benchmark execution time: 2025-08-05 16:10:46

Comparing candidate commit 6df661a in PR branch glopes/symfony-route with baseline commit 38ce35a in branch master.

Found 1 performance improvements and 2 performance regressions! Performance is the same for 175 metrics, 0 unstable metrics.

scenario:PDOBench/benchPDOBaseline

  • 🟥 execution_time [+4.595µs; +5.449µs] or [+7.355%; +8.723%]

scenario:PDOBench/benchPDOBaseline-opcache

  • 🟩 execution_time [-4.522µs; -3.613µs] or [-6.729%; -5.376%]

scenario:SymfonyBench/benchSymfonyOverhead-opcache

  • 🟥 execution_time [+162.887µs; +271.453µs] or [+2.059%; +3.431%]

@cataphract cataphract force-pushed the glopes/symfony-route branch 2 times, most recently from 1c181cf to 387a651 Compare December 12, 2024 14:41
Copy link
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

@cataphract cataphract force-pushed the glopes/symfony-route branch 6 times, most recently from 644c737 to ddbe994 Compare December 16, 2024 21:27
@@ -913,7 +913,6 @@ TEST_WEB_81 := \
test_web_nette_30 \
test_web_slim_312 \
test_web_slim_4 \
test_web_symfony_52 \
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we removing those tests from PHP 8.1 up to PHP 8.3? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Symfony 5.2 doesn't actually work with those PHP versions. The tests fail with:

[17-Dec-2024 19:40:57 -03] [ddtrace] [warning] Error raised in ddtrace's closure defined at /Users/gustavo.lopes/repos/dd-trace-php/src/DDTrace/Integrations/Symfony/SymfonyIntegration.php:394 for Symfony\Component\HttpKernel\HttpKernel::handle(): Return type of Symfony\Component\Routing\RouteCollection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/gustavo.lopes/repos/dd-trace-php/tests/Frameworks/Symfony/Version_5_2/vendor/symfony/routing/RouteCollection.php on line 69
 /Users/gustavo.lopes/repos/dd-trace-php/tests/Common/WebFrameworkTestCase.php:74
 /Users/gustavo.lopes/repos/dd-trace-php/tests/Common/MultiPHPUnitVersionAdapter_typed.php:33

Copy link
Contributor

Choose a reason for hiding this comment

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

I can see that version of symfony being executed on the pipeline: https://app.circleci.com/pipelines/github/DataDog/dd-trace-php/19819/workflows/69eaa9d7-067a-40e8-9a0c-5bd35b27e5a1/jobs/6415988
P.S: I didn't check any more of the combinations deleted below

Copy link
Contributor

@PROFeNoM PROFeNoM left a comment

Choose a reason for hiding this comment

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

FYI, I can see the following warning/error from our CI: failure.

On a similar note, the Symfony 3.0 (:skull:) tests seems not to have the http.route tag: failure

@estringana
Copy link
Contributor

}
$rootSpan->meta['symfony.route.name'] = $route_name;

// the rest is for determining http.route
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather extract then all the code below this comment to its own function. Comments sooner or later lie. Just my opinion, not blocking the pr or anything

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've refactored it

*/
public function dynamicAction(Request $request)
#[Route("/dynamic-path/{param01}", locale: "en")]
#[Route("/caminho-dinamico/{param01}", locale: "pt")]
Copy link
Contributor

Choose a reason for hiding this comment

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

How is the PT route reported if locale is pt. I can't see any test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't report the routes and I don't hit this route, only then en one. The point is that there being several locales forces the route name not be a key in the route collection; instead we get route_name.locale.

@cataphract cataphract force-pushed the glopes/symfony-route branch from ee8946d to 04884ce Compare January 15, 2025 20:20
@cataphract cataphract force-pushed the glopes/symfony-route branch from 04884ce to 1a756da Compare March 7, 2025 10:30
@cataphract cataphract force-pushed the glopes/symfony-route branch from 1a756da to 9dcb398 Compare March 7, 2025 10:30
} else {
$routeCollection = $router->getRouteCollection();
$route = $routeCollection->get($route_name);
if ($route == null && ($locale = $request->get('_locale')) !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You have $locale already above

@cataphract cataphract force-pushed the glopes/symfony-route branch from ee457d5 to ec2d9b2 Compare April 10, 2025 10:06
@cataphract cataphract requested a review from estringana April 10, 2025 14:51
@cataphract cataphract force-pushed the glopes/symfony-route branch from b11f5e6 to 6df661a Compare August 5, 2025 15:35
@cataphract cataphract merged commit 6ec272b into master Aug 6, 2025
1838 of 1857 checks passed
@cataphract cataphract deleted the glopes/symfony-route branch August 6, 2025 16:10
@github-actions github-actions bot added this to the 1.12.0 milestone Aug 6, 2025
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.

5 participants