@@ -196,7 +196,7 @@ def response_hook(span: Span, params: typing.Union[
196196import types
197197import typing
198198from timeit import default_timer
199- from typing import Callable , Collection , Mapping
199+ from typing import Collection
200200from urllib .parse import urlparse
201201
202202import aiohttp
@@ -244,13 +244,12 @@ def response_hook(span: Span, params: typing.Union[
244244 OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_REQUEST ,
245245 OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_RESPONSE ,
246246 OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS ,
247- SanitizeValue ,
248247 get_custom_headers ,
249248 get_excluded_urls ,
250249 normalise_request_header_name ,
251250 normalise_response_header_name ,
252251 redact_url ,
253- sanitize_method ,
252+ sanitize_method , get_custom_header_attributes ,
254253)
255254
256255_UrlFilterT = typing .Optional [typing .Callable [[yarl .URL ], str ]]
@@ -304,35 +303,6 @@ def _set_http_status_code_attribute(
304303 )
305304
306305
307- def _get_custom_header_attributes (
308- headers : typing .Optional [Mapping [str , typing .Union [str , list [str ]]]],
309- captured_headers : typing .Optional [list [str ]],
310- sensitive_headers : typing .Optional [list [str ]],
311- normalize_function : Callable [[str ], str ],
312- ) -> dict [str , list [str ]]:
313- """Extract and sanitize HTTP headers for span attributes.
314-
315- Args:
316- headers: The HTTP headers to process, either from a request or response.
317- Can be None if no headers are available.
318- captured_headers: List of header regexes to capture as span attributes.
319- If None or empty, no headers will be captured.
320- sensitive_headers: List of header regexes whose values should be sanitized
321- (redacted). If None, no sanitization is applied.
322- normalize_function: Function to normalize header names.
323-
324- Returns:
325- Dictionary of normalized header attribute names to their values
326- as lists of strings.
327- """
328- if not headers or not captured_headers :
329- return {}
330- sanitize : SanitizeValue = SanitizeValue (sensitive_headers or ())
331- return sanitize .sanitize_header_values (
332- headers , captured_headers , normalize_function
333- )
334-
335-
336306# pylint: disable=too-many-locals
337307# pylint: disable=too-many-statements
338308def create_trace_config (
@@ -525,7 +495,7 @@ async def on_request_start(
525495 pass
526496
527497 span_attributes .update (
528- _get_custom_header_attributes (
498+ get_custom_header_attributes (
529499 {
530500 key : params .headers .getall (key )
531501 for key in params .headers .keys ()
@@ -567,7 +537,7 @@ async def on_request_end(
567537 )
568538
569539 trace_config_ctx .span .set_attributes (
570- _get_custom_header_attributes (
540+ get_custom_header_attributes (
571541 {
572542 key : params .response .headers .getall (key )
573543 for key in params .response .headers .keys ()
0 commit comments