Title: Use `request.path_info` to create Django transaction name · Issue #998 · getsentry/sentry-python · GitHub
Open Graph Title: Use `request.path_info` to create Django transaction name · Issue #998 · getsentry/sentry-python
X Title: Use `request.path_info` to create Django transaction name · Issue #998 · getsentry/sentry-python
Description: Currently, the Django integration creates a transaction from the request URL by calling LEGACY_RESOLVER.resolve(request.path). This transforms URLS such as /test/1/ into /test/{pk}/. However, if the Django application is served from a no...
Open Graph Description: Currently, the Django integration creates a transaction from the request URL by calling LEGACY_RESOLVER.resolve(request.path). This transforms URLS such as /test/1/ into /test/{pk}/. However, if th...
X Description: Currently, the Django integration creates a transaction from the request URL by calling LEGACY_RESOLVER.resolve(request.path). This transforms URLS such as /test/1/ into /test/{pk}/. However, if th...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/998
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use `request.path_info` to create Django transaction name","articleBody":"Currently, the Django integration creates a transaction from the request URL by calling `LEGACY_RESOLVER.resolve(request.path)`. This transforms URLS such as `/test/1/` into `/test/{pk}/`.\r\n\r\nHowever, if the Django application is served from a non-root path, such as `/django/`, `request.path` becomes `/django/test/1/`. Django only processes the `/test/1/` part, which is accessible in `request.path_info`, but the transaction becomes `/django/test/1/`.\r\n\r\nTo demonstrate this, I created a new Django project and added the setting `FORCE_SCRIPT_NAME = \"/test\"` to `settings.py`.\r\nI then created the following view:\r\n\r\n```python\r\nfrom django.http.response import JsonResponse\r\n\r\nfrom sentry_sdk.integrations.django.transactions import LEGACY_RESOLVER\r\n\r\n\r\ndef show_example(request, *args, **kwargs):\r\n return JsonResponse(\r\n {\r\n \"current\": LEGACY_RESOLVER.resolve(request.path),\r\n \"correct\": LEGACY_RESOLVER.resolve(request.path_info),\r\n }\r\n )\r\n```\r\n\r\nI added\r\n```python\r\npath('\u003cint:pk>/\u003cvar>/', views.show_example)\r\n```\r\nto the `urlpatterns`, then executed the `runserver` management command.\r\n\r\nHere is the output of `curl http://localhost:8000/1/@/`:\r\n```json\r\n{\"current\": \"/test/1/@/\", \"correct\": \"/{pk}/{var}/\"}\r\n```\r\n","author":{"url":"https://github.com/OutOfFocus4","@type":"Person","name":"OutOfFocus4"},"datePublished":"2021-02-05T15:57:40Z","url":"https://github.com/getsentry/sentry-python/issues/998"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8df2a8e5-38c8-bc24-18d4-a92ab31a54f0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ACEC:22B103:56D0B9:749DCC:6B009123 |
| html-safe-nonce | ce545d2374ec8a05766c27732b5478de4f89e8ff710d6b4fe8ea0b5a20781f29 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQ0VDOjIyQjEwMzo1NkQwQjk6NzQ5RENDOjZCMDA5MTIzIiwidmlzaXRvcl9pZCI6IjQ0OTM3NjY5MzI5MDE2OTU3NzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 56d089a904401956b3bfc19025ffa897c5c186b8e222ca69a812be02f3eb4e27 |
| hovercard-subject-tag | issue:802278872 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/998/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3cae552fc42940a573aaaabee7189c38c501b0d3ffa9bbe4f23080320770a8de/getsentry/sentry-python/issues/998 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3cae552fc42940a573aaaabee7189c38c501b0d3ffa9bbe4f23080320770a8de/getsentry/sentry-python/issues/998 |
| og:image:alt | Currently, the Django integration creates a transaction from the request URL by calling LEGACY_RESOLVER.resolve(request.path). This transforms URLS such as /test/1/ into /test/{pk}/. However, if th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | OutOfFocus4 |
| hostname | github.com |
| expected-hostname | github.com |
| None | c710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | be616a2a6ec1c609d6e002896dff5352d5c5f28b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width