diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py index c665fdc3f8..7388a603ff 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/callbacks.py @@ -42,6 +42,7 @@ ERROR_TYPE, ) from opentelemetry.semconv._incubating.attributes.http_attributes import ( + HTTP_RESPONSE_STATUS_CODE, HTTP_STATUS_CODE, ) from opentelemetry.semconv.attributes.http_attributes import HTTP_ROUTE @@ -265,9 +266,8 @@ def trace_tween(request): status = getattr(response, "status", status) status_code = otel_wsgi._parse_status_code(status) if status_code is not None: - duration_attrs[HTTP_STATUS_CODE] = ( - otel_wsgi._parse_status_code(status) - ) + duration_attrs[HTTP_STATUS_CODE] = status_code + duration_attrs[HTTP_RESPONSE_STATUS_CODE] = status_code # Record metrics for old semconv (milliseconds) if duration_histogram_old: diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_automatic.py b/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_automatic.py index 8686e4c527..c3cc18ee8f 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_automatic.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_automatic.py @@ -480,6 +480,7 @@ def _verify_metric_names( def _verify_duration_point(self, point): self.assertIn(HTTP_REQUEST_METHOD, point.attributes) + self.assertIn(HTTP_RESPONSE_STATUS_CODE, point.attributes) self.assertIn(URL_SCHEME, point.attributes) self.assertNotIn(HTTP_METHOD, point.attributes) self.assertNotIn(HTTP_SCHEME, point.attributes)