mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-29 21:23:55 +08:00
Add http.target
to Django duration metric attributes (#2624)
This commit is contained in:
@ -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))
|
([#2652](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2652))
|
||||||
- `opentelemetry-instrumentation-aiohttp-client` Implement new semantic convention opt-in migration
|
- `opentelemetry-instrumentation-aiohttp-client` Implement new semantic convention opt-in migration
|
||||||
([#2673](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2673))
|
([#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
|
### Breaking changes
|
||||||
|
|
||||||
|
@ -315,6 +315,12 @@ class _DjangoMiddleware(MiddlewareMixin):
|
|||||||
route = getattr(match, "route", None)
|
route = getattr(match, "route", None)
|
||||||
if route:
|
if route:
|
||||||
span.set_attribute(SpanAttributes.HTTP_ROUTE, route)
|
span.set_attribute(SpanAttributes.HTTP_ROUTE, route)
|
||||||
|
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):
|
def process_exception(self, request, exception):
|
||||||
if self._excluded_urls.url_disabled(request.build_absolute_uri("?")):
|
if self._excluded_urls.url_disabled(request.build_absolute_uri("?")):
|
||||||
|
@ -480,7 +480,8 @@ class TestMiddleware(WsgiTestBase):
|
|||||||
]
|
]
|
||||||
_recommended_attrs = {
|
_recommended_attrs = {
|
||||||
"http.server.active_requests": _active_requests_count_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()
|
start = default_timer()
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
|
Reference in New Issue
Block a user