diff --git a/CHANGELOG.md b/CHANGELOG.md index df68c6593d..9b45f3cfe5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py index b651d94c53..7fcd3dd158 100644 --- a/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py +++ b/instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py @@ -191,9 +191,9 @@ def process_view(self, request, view_func, *args, **kwargs): 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)