Skip to content

fix(laravel): use route URI instead of unnamed_route in resource name#3761

Merged
Leiyks merged 1 commit intomasterfrom
leiyks/fix-apms-18982
Apr 1, 2026
Merged

fix(laravel): use route URI instead of unnamed_route in resource name#3761
Leiyks merged 1 commit intomasterfrom
leiyks/fix-apms-18982

Conversation

@Leiyks
Copy link
Copy Markdown
Contributor

@Leiyks Leiyks commented Apr 1, 2026

Summary

When DD_HTTP_SERVER_ROUTE_BASED_NAMING is enabled (default), routes defined without a ->name() call produced resource names like:

App\Http\Controllers\API\v1\Apps\AppsController@getStripeConnectionToken unnamed_route

For unnamed routes, the unnamed_route suffix is now replaced with the actual route URI:

App\Http\Controllers\API\v1\Apps\AppsController@getStripeConnectionToken stripe/connection

Named routes are fully unaffected.

Fixes APMS-18982.

Root cause

LaravelIntegration::findRoute sets the resource to {action} {routeName}. For routes defined with the old string syntax (Route::get('path', 'Controller@method')) or any route without ->name(), normalizeRouteName() returns the constant 'unnamed_route'. There was no fallback — the literal string ended up in the resource.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

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

9 occurrences of :

- "resource": "App\\Http\\Controllers\\CommonSpecsController@error unnamed_route"
+ "resource": "App\\Http\\Controllers\\CommonSpecsController@error error"

7 occurrences of :

- "resource": "App\\Http\\Controllers\\CommonSpecsController@simple_view unnamed_route"
+ "resource": "App\\Http\\Controllers\\CommonSpecsController@simple_view simple_view"

3 occurrences of :

- "resource": "App\\Http\\Controllers\\CommonSpecsController@dynamicRoute unnamed_route"
+ "resource": "App\\Http\\Controllers\\CommonSpecsController@dynamicRoute dynamic_route/{param01}/static/{param02?}"

@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

datadog-datadog-prod-us1-2 bot commented Apr 1, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 4 Tests failed

testScenarioGetWithException from laravel-octane-latest-test.DDTrace\Tests\Integrations\Laravel\Octane\Latest\CommonScenariosTest   View in Datadog   (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\Octane\Latest\CommonScenariosTest::testScenarioGetWithException
Cannot find span
  - Current level: root/root
  - Span not found: laravel.request/App\Http\Controllers\CommonSpecsController@error unnamed_route
Received Spans graph:
laravel.request (service: swoole_test_app, resource: App\Http\Controllers\CommonSpecsController@error error, type: web)
  runtime-id => 6d8cbb3b-c122-424c-822d-3cc4d94735bb
  http.url => http://localhost/error?key=value&<redacted>
  http.status_code => 500
  laravel.route.action => App\Http\Controllers\CommonSpecsController@error
...
testScenarioGetWithView from laravel-octane-latest-test.DDTrace\Tests\Integrations\Laravel\Octane\Latest\CommonScenariosTest   View in Datadog   (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\Octane\Latest\CommonScenariosTest::testScenarioGetWithView
Cannot find span
  - Current level: root/root
  - Span not found: laravel.request/App\Http\Controllers\CommonSpecsController@simple_view unnamed_route
Received Spans graph:
laravel.request (service: swoole_test_app, resource: App\Http\Controllers\CommonSpecsController@simple_view simple_view, type: web)
  runtime-id => 6d8cbb3b-c122-424c-822d-3cc4d94735bb
  component => laravel
  laravel.route.action => App\Http\Controllers\CommonSpecsController@simple_view
  http.route => simple_view
...
❄️ Known flaky: testAsyncWithTracerDisabledOnConsume from symfony-latest-test.DDTrace\Tests\Integrations\Symfony\Latest\MessengerTest   View in Datadog   (Fix with Cursor)
DDTrace\Tests\Integrations\Symfony\Latest\MessengerTest::testAsyncWithTracerDisabledOnConsume
Command failed with exit code 1. Output: 
 [OK] Consuming messages from transport "async".

 // The worker will automatically exit once it has processed 1 messages or
 // received a stop signal via the messenger:stop-workers command.

 // Quit the worker with CONTROL-C.

 // Re-run the command with a -vv option to see logs about consumed messages.
...
testScenario with data set "A GET request to a dynamic route returning a string" from tests/Integrations/Laravel/V4.DDTrace\Tests\Integrations\Laravel\V4\CommonScenariosTest.DDTrace\Tests\Integrations\Laravel\V4\CommonScenariosTest::testScenario   View in Datadog   (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\V4\CommonScenariosTest::testScenario with data set "A GET request to a dynamic route returning a string" (DDTrace\Tests\Frameworks\Util\Request\GetSpec Object (...), array(DDTrace\Tests\Common\SpanAssertion Object (...)))
Cannot find span
  - Current level: root/root
  - Span not found: laravel.request/HomeController@dynamicRoute unnamed_route
Received Spans graph:
laravel.request (service: laravel, resource: HomeController@dynamicRoute dynamic_route/{param01}/static/{param02?}, type: web)
  runtime-id => c5dfbb75-bcb5-4f1a-ae25-0435fa1c12f6
  http.method => GET
  http.url => http://localhost/dynamic_route/dynamic01/static/dynamic02
  span.kind => server
...
View all

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.64% (-0.05%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 4f6a72b | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@Leiyks Leiyks force-pushed the leiyks/fix-apms-18982 branch from e796c0c to f286f9c Compare April 1, 2026 12:55
When DD_HTTP_SERVER_ROUTE_BASED_NAMING is enabled (default), routes
defined without a ->name() call produced resources like:

  App\Http\Controllers\FooController@bar unnamed_route

This was unhelpful and inconsistent with named routes. For unnamed
routes, fall back to `{HTTP_METHOD} {route_uri}` (e.g. `GET error`),
which matches the format customers already see for named routes and
gives a meaningful, actionable resource name.

Named routes are unaffected.

Fixes APMS-18982
@Leiyks Leiyks force-pushed the leiyks/fix-apms-18982 branch from f286f9c to 4f6a72b Compare April 1, 2026 14:02
@Leiyks Leiyks marked this pull request as ready for review April 1, 2026 14:14
@Leiyks Leiyks requested review from a team as code owners April 1, 2026 14:14
Copy link
Copy Markdown
Collaborator

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

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

Looks good, nice fix.

@Leiyks Leiyks merged commit 1111e80 into master Apr 1, 2026
2069 of 2099 checks passed
@Leiyks Leiyks deleted the leiyks/fix-apms-18982 branch April 1, 2026 16:32
@github-actions github-actions bot added this to the 1.18.0 milestone Apr 1, 2026
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.

2 participants