Skip to content

Commit 10fa0c7

Browse files
committed
fix django response
1 parent 61a7354 commit 10fa0c7

File tree

1 file changed

+17
-9
lines changed
  • instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware

1 file changed

+17
-9
lines changed

instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware/otel_middleware.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ def __call__(self, request):
9696
try:
9797
from opentelemetry.instrumentation.asgi import asgi_getter, asgi_setter
9898
from opentelemetry.instrumentation.asgi import (
99-
collect_custom_headers_attributes as asgi_collect_custom_request_attributes,
100-
)
101-
from opentelemetry.instrumentation.asgi import (
102-
collect_custom_response_headers_attributes as asgi_collect_custom_response_attributes,
99+
collect_custom_headers_attributes as asgi_collect_custom_headers_attributes,
103100
)
104101
from opentelemetry.instrumentation.asgi import (
105102
collect_request_attributes as asgi_collect_request_attributes,
@@ -254,16 +251,16 @@ def process_request(self, request):
254251
)
255252
if span.is_recording() and span.kind == SpanKind.SERVER:
256253
attributes.update(
257-
asgi_collect_custom_request_attributes(
254+
asgi_collect_custom_headers_attributes(
258255
carrier,
259-
get_custom_headers(
260-
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST
261-
),
262256
SanitizeValue(
263257
get_custom_headers(
264258
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS
265259
)
266260
),
261+
get_custom_headers(
262+
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST
263+
),
267264
normalise_request_header_name,
268265
)
269266
)
@@ -353,7 +350,18 @@ def process_response(self, request, response):
353350
asgi_setter.set(custom_headers, key, value)
354351

355352
custom_res_attributes = (
356-
asgi_collect_custom_response_attributes(custom_headers)
353+
asgi_collect_custom_headers_attributes(
354+
custom_headers,
355+
SanitizeValue(
356+
get_custom_headers(
357+
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS
358+
)
359+
),
360+
get_custom_headers(
361+
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST
362+
),
363+
normalise_request_header_name,
364+
)
357365
)
358366
for key, value in custom_res_attributes.items():
359367
span.set_attribute(key, value)

0 commit comments

Comments
 (0)