Skip to content

Commit df0ca3b

Browse files
authored
Fix AttributeError: ResolverMatch object has no attribute route (#581)
1 parent 2ccf120 commit df0ca3b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4141
- `opentelemetry-instrumentation-requests` Fix potential `AttributeError` when `requests`
4242
is used with a custom transport adapter.
4343
([#562](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/562))
44+
- `opentelemetry-instrumentation-django` Fix AttributeError: ResolverMatch object has no attribute route
45+
([#581](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/581))
4446

4547
### Added
4648
- `opentelemetry-instrumentation-httpx` Add `httpx` instrumentation

instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ def process_view(self, request, view_func, *args, **kwargs):
191191
span = request.META[self._environ_span_key]
192192

193193
if span.is_recording():
194-
match = getattr(request, "resolver_match")
194+
match = getattr(request, "resolver_match", None)
195195
if match:
196-
route = getattr(match, "route")
196+
route = getattr(match, "route", None)
197197
if route:
198198
span.set_attribute(SpanAttributes.HTTP_ROUTE, route)
199199

0 commit comments

Comments
 (0)