Skip to content

[Routing] always add _route_path as request attribute #47970

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

Closed
wants to merge 1 commit into from
Closed

[Routing] always add _route_path as request attribute #47970

wants to merge 1 commit into from

Conversation

cdaguerre
Copy link

@cdaguerre cdaguerre commented Oct 24, 2022

Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #41426
License MIT
Doc PR n.a

This PR adds the _path attribute to attributes returned by the request matcher.
If I'm not mistaken, this information is actually hard to get without using the RouteCollection at runtime or manipulating cache files directly (be they generated by the routing cache warmer or by a custom cache warmer).
I'b be glad to add/fix tests if there is an agreement on the principle ;)

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

Hello @cdaguerre. Thanks opening this PR while you explore alternative solutions.

Major APM (datadog, newrelic and instana) use the route name to name the span. This keep distinction between routes with the same path pattern but distinct host/condition/requirements...

@wouterj wouterj modified the milestones: 6.2, 6.3 Oct 24, 2022
@cdaguerre
Copy link
Author

Major APM (datadog, newrelic and instana) use the route name to name the span. This keep distinction between routes with the same path pattern but distinct host/condition/requirements...

That is indeed one of the alternatives. However, it is not really compliant with OpenTelemetry's semantic conventions...
Disambiguating/distinguishing host etc. is done with other attributes like http.scheme, net.host.name.

@OskarStark OskarStark changed the title [Routing] always add _path as request attribute [Routing] always add _path as request attribute Oct 24, 2022
@cdaguerre cdaguerre changed the title [Routing] always add _path as request attribute [Routing] always add _route_path as request attribute Oct 25, 2022
@cdaguerre
Copy link
Author

I made the changes you requested and fixed the tests.
Failing tests on 8.1 seem unrelated to these changes.
However, I need your advice on fixing the high/low-deps tests, because these tests succeed in 8.1 and 8.2 and I'm not sure what I should do here.

@Tobion
Copy link
Contributor

Tobion commented Oct 29, 2022

I can see that having the route path available might be useful. But it seems arbitrary to me that the returned values include the route path but none of the other route information like route host, scheme etc.
So this does not seem like the right solution to me.

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

Same opinion. Getting raw route config from the requests is only a partial solution for your need.

There is a risk that these values will be misused to generate urls.

@GromNaN
Copy link
Member

GromNaN commented Nov 2, 2022

Hi @cdaguerre, I closed your MR because we think this informations should not be exposed as this. I see you found an alternative in worldia/instrumentation-bundle#12 that is good and allows more specific code.

@cdaguerre
Copy link
Author

alright, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a route pattern (route path) to the UrlMatcher/RouterListener
5 participants