Skip to content
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

Add http.target to Django duration metric attributes #2624

Merged
merged 8 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2652](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2652))
- `opentelemetry-instrumentation-aiohttp-client` Implement new semantic convention opt-in migration
([#2673](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2673))
- `opentelemetry-instrumentation-django` Add `http.target` to Django duration metric attributes
([#2624](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2624))

### Breaking changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ def process_view(self, request, view_func, *args, **kwargs):
route = getattr(match, "route", None)
if route:
span.set_attribute(SpanAttributes.HTTP_ROUTE, route)
alexmojaki marked this conversation as resolved.
Show resolved Hide resolved
duration_attrs = request.META[
self._environ_duration_attr_key
]
# Metrics currently use the 1.11.0 schema, which puts the route in `http.target`.
# TODO: use `http.route` when the user sets `OTEL_SEMCONV_STABILITY_OPT_IN`.
duration_attrs[SpanAttributes.HTTP_TARGET] = route

def process_exception(self, request, exception):
if self._excluded_urls.url_disabled(request.build_absolute_uri("?")):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ def test_wsgi_metrics(self):
]
_recommended_attrs = {
"http.server.active_requests": _active_requests_count_attrs,
"http.server.duration": _duration_attrs,
"http.server.duration": _duration_attrs
| {SpanAttributes.HTTP_TARGET},
}
start = default_timer()
for _ in range(3):
Expand Down