|
8 | 8 | from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict |
9 | 9 |
|
10 | 10 | from opentelemetry.semconv.trace import SpanAttributes |
11 | | -from opentelemetry.trace import SpanKind |
12 | 11 |
|
13 | 12 | from instana.log import logger |
14 | 13 | from instana.propagators.format import Format |
15 | | -from instana.singletons import agent, tracer |
| 14 | +from instana.singletons import agent, get_tracer |
16 | 15 | from instana.util.secrets import strip_secrets_from_query |
17 | 16 | from instana.util.traceutils import extract_custom_headers |
18 | 17 |
|
@@ -66,6 +65,7 @@ async def __call__( |
66 | 65 | send: Callable[[Dict[str, Any]], Awaitable[None]], |
67 | 66 | ) -> None: |
68 | 67 | request_context = None |
| 68 | + tracer = get_tracer() |
69 | 69 |
|
70 | 70 | if scope["type"] not in ("http", "websocket"): |
71 | 71 | return await self.app(scope, receive, send) |
@@ -104,11 +104,14 @@ async def send_wrapper(response: Dict[str, Any]) -> Awaitable[None]: |
104 | 104 | if status_code: |
105 | 105 | if 500 <= int(status_code): |
106 | 106 | current_span.mark_as_errored() |
107 | | - current_span.set_attribute(SpanAttributes.HTTP_STATUS_CODE, status_code) |
| 107 | + current_span.set_attribute( |
| 108 | + SpanAttributes.HTTP_STATUS_CODE, status_code |
| 109 | + ) |
108 | 110 |
|
109 | 111 | headers = response.get("headers") |
110 | 112 | if headers: |
111 | 113 | extract_custom_headers(current_span, headers) |
| 114 | + tracer = get_tracer() |
112 | 115 | tracer.inject(current_span.context, Format.BINARY, headers) |
113 | 116 | except Exception: |
114 | 117 | logger.debug("ASGI send_wrapper error: ", exc_info=True) |
|
0 commit comments