|
4 | 4 | from sentry_sdk.integrations import Integration, DidNotEnable |
5 | 5 | from sentry_sdk.tracing import BAGGAGE_HEADER_NAME |
6 | 6 | from sentry_sdk.tracing_utils import ( |
7 | | - Baggage, |
8 | 7 | should_propagate_trace, |
9 | 8 | add_http_request_source, |
| 9 | + add_sentry_baggage_to_headers, |
10 | 10 | ) |
11 | 11 | from sentry_sdk.utils import ( |
12 | 12 | SENSITIVE_DATA_SUBSTITUTE, |
|
19 | 19 | from typing import TYPE_CHECKING |
20 | 20 |
|
21 | 21 | if TYPE_CHECKING: |
22 | | - from collections.abc import MutableMapping |
23 | 22 | from typing import Any |
24 | 23 |
|
25 | 24 |
|
@@ -81,7 +80,7 @@ def send(self: "Client", request: "Request", **kwargs: "Any") -> "Response": |
81 | 80 | ) |
82 | 81 |
|
83 | 82 | if key == BAGGAGE_HEADER_NAME: |
84 | | - _add_sentry_baggage_to_headers(request.headers, value) |
| 83 | + add_sentry_baggage_to_headers(request.headers, value) |
85 | 84 | else: |
86 | 85 | request.headers[key] = value |
87 | 86 |
|
@@ -155,22 +154,3 @@ async def send( |
155 | 154 | return rv |
156 | 155 |
|
157 | 156 | AsyncClient.send = send |
158 | | - |
159 | | - |
160 | | -def _add_sentry_baggage_to_headers( |
161 | | - headers: "MutableMapping[str, str]", sentry_baggage: str |
162 | | -) -> None: |
163 | | - """Add the Sentry baggage to the headers. |
164 | | -
|
165 | | - This function directly mutates the provided headers. The provided sentry_baggage |
166 | | - is appended to the existing baggage. If the baggage already contains Sentry items, |
167 | | - they are stripped out first. |
168 | | - """ |
169 | | - existing_baggage = headers.get(BAGGAGE_HEADER_NAME, "") |
170 | | - stripped_existing_baggage = Baggage.strip_sentry_baggage(existing_baggage) |
171 | | - |
172 | | - separator = "," if len(stripped_existing_baggage) > 0 else "" |
173 | | - |
174 | | - headers[BAGGAGE_HEADER_NAME] = ( |
175 | | - stripped_existing_baggage + separator + sentry_baggage |
176 | | - ) |
0 commit comments