Skip to content

Commit 2d4bf40

Browse files
committed
fix django middleware
1 parent 2e0c109 commit 2d4bf40

File tree

1 file changed

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

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@
4343
from opentelemetry.semconv.trace import SpanAttributes
4444
from opentelemetry.trace import Span, SpanKind, use_span
4545
from opentelemetry.util.http import (
46+
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS,
47+
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST,
48+
SanitizeValue,
4649
_parse_active_request_count_attrs,
4750
_parse_duration_attrs,
51+
get_custom_headers,
4852
get_excluded_urls,
4953
get_traced_request_attrs,
54+
normalise_request_header_name,
5055
)
5156

5257
try:
@@ -249,7 +254,18 @@ def process_request(self, request):
249254
)
250255
if span.is_recording() and span.kind == SpanKind.SERVER:
251256
attributes.update(
252-
asgi_collect_custom_request_attributes(carrier)
257+
asgi_collect_custom_request_attributes(
258+
carrier,
259+
get_custom_headers(
260+
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST
261+
),
262+
SanitizeValue(
263+
get_custom_headers(
264+
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS
265+
)
266+
),
267+
normalise_request_header_name,
268+
)
253269
)
254270
else:
255271
if span.is_recording() and span.kind == SpanKind.SERVER:

0 commit comments

Comments
 (0)