Fix AttributeError: `ResolverMatch` object has no attribute `route` (#581)

This commit is contained in:
Srikanth Chekuri 2021-07-14 23:52:29 +05:30 committed by GitHub
parent 2ccf12055e
commit df0ca3b604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-instrumentation-requests` Fix potential `AttributeError` when `requests`
is used with a custom transport adapter.
([#562](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/562))
- `opentelemetry-instrumentation-django` Fix AttributeError: ResolverMatch object has no attribute route
([#581](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/581))
### Added
- `opentelemetry-instrumentation-httpx` Add `httpx` instrumentation

View File

@ -191,9 +191,9 @@ class _DjangoMiddleware(MiddlewareMixin):
span = request.META[self._environ_span_key]
if span.is_recording():
match = getattr(request, "resolver_match")
match = getattr(request, "resolver_match", None)
if match:
route = getattr(match, "route")
route = getattr(match, "route", None)
if route:
span.set_attribute(SpanAttributes.HTTP_ROUTE, route)