Skip to content

Commit

Permalink
Re-add http.target to Django old sem conv server duration metric (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen authored Jul 30, 2024
1 parent 35cc6f2 commit b65f67d
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 144 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- `opentelemetry-instrumentation-django` Fix regression - `http.target` re-added back to old semconv duration metrics
([#2746](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2746))

## Version 1.26.0/0.47b0 (2024-07-23)

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def process_exception(self, request, exception):

# pylint: disable=too-many-branches
# pylint: disable=too-many-locals
# pylint: disable=too-many-statements
def process_response(self, request, response):
if self._excluded_urls.url_disabled(request.build_absolute_uri("?")):
return response
Expand Down Expand Up @@ -426,6 +427,10 @@ def process_response(self, request, response):
duration_attrs_old = _parse_duration_attrs(
duration_attrs, _HTTPStabilityMode.DEFAULT
)
# http.target to be included in old semantic conventions
target = duration_attrs.get(SpanAttributes.HTTP_TARGET)
if target:
duration_attrs_old[SpanAttributes.HTTP_TARGET] = target
self._duration_histogram_old.record(
max(round(duration_s * 1000), 0), duration_attrs_old
)
Expand Down
Loading

0 comments on commit b65f67d

Please sign in to comment.