|
5 | 5 | import sentry_sdk |
6 | 6 | from sentry_sdk.data_collection import _apply_data_collection_filtering_to_query_string |
7 | 7 | from sentry_sdk.integrations._wsgi_common import _filter_headers |
8 | | -from sentry_sdk.scope import should_send_default_pii |
9 | | -from sentry_sdk.utils import has_data_collection_enabled |
10 | 8 |
|
11 | 9 | if TYPE_CHECKING: |
12 | 10 | from typing import Any, Dict, Optional, Union |
@@ -171,64 +169,36 @@ def _get_request_attributes( |
171 | 169 | for header, value in filtered_headers.items(): |
172 | 170 | attributes[f"http.request.header.{header.lower()}"] = [value] |
173 | 171 |
|
174 | | - if has_data_collection_enabled(client_options): |
175 | | - filtered_query_string = None |
176 | | - query = _get_query(asgi_scope) |
177 | | - |
178 | | - if query: |
179 | | - filtered_query_string = ( |
180 | | - _apply_data_collection_filtering_to_query_string( |
181 | | - query_string=query, |
182 | | - behaviour=client_options["data_collection"]["url_query_params"], |
183 | | - ) |
184 | | - ) |
185 | | - if filtered_query_string: |
186 | | - attributes["http.query"] = filtered_query_string |
187 | | - |
188 | | - path = _get_path(asgi_scope=asgi_scope, root_path_in_path=root_path_in_path) |
189 | | - attributes["url.path"] = path |
190 | | - |
191 | | - url_without_query_string = _get_url( |
192 | | - asgi_scope, |
193 | | - "http" if ty == "http" else "ws", |
194 | | - headers.get("host"), |
195 | | - path=path, |
196 | | - ) |
| 172 | + filtered_query_string = None |
| 173 | + query = _get_query(asgi_scope) |
197 | 174 |
|
198 | | - attributes["url.full"] = ( |
199 | | - f"{url_without_query_string}?{filtered_query_string}" |
200 | | - if filtered_query_string is not None |
201 | | - else url_without_query_string |
| 175 | + if query: |
| 176 | + filtered_query_string = _apply_data_collection_filtering_to_query_string( |
| 177 | + query_string=query, |
| 178 | + behaviour=client_options["data_collection"]["url_query_params"], |
202 | 179 | ) |
| 180 | + if filtered_query_string: |
| 181 | + attributes["http.query"] = filtered_query_string |
203 | 182 |
|
204 | | - elif should_send_default_pii(): |
205 | | - query = _get_query(asgi_scope) |
206 | | - if query: |
207 | | - attributes["http.query"] = query |
| 183 | + path = _get_path(asgi_scope=asgi_scope, root_path_in_path=root_path_in_path) |
| 184 | + attributes["url.path"] = path |
208 | 185 |
|
209 | | - path = _get_path(asgi_scope=asgi_scope, root_path_in_path=root_path_in_path) |
210 | | - attributes["url.path"] = path |
| 186 | + url_without_query_string = _get_url( |
| 187 | + asgi_scope, |
| 188 | + "http" if ty == "http" else "ws", |
| 189 | + headers.get("host"), |
| 190 | + path=path, |
| 191 | + ) |
211 | 192 |
|
212 | | - url_without_query_string = _get_url( |
213 | | - asgi_scope, |
214 | | - "http" if ty == "http" else "ws", |
215 | | - headers.get("host"), |
216 | | - path=path, |
217 | | - ) |
218 | | - query_string = _get_query(asgi_scope) |
219 | | - attributes["url.full"] = ( |
220 | | - f"{url_without_query_string}?{query_string}" |
221 | | - if query_string is not None |
222 | | - else url_without_query_string |
223 | | - ) |
| 193 | + attributes["url.full"] = ( |
| 194 | + f"{url_without_query_string}?{filtered_query_string}" |
| 195 | + if filtered_query_string is not None |
| 196 | + else url_without_query_string |
| 197 | + ) |
224 | 198 |
|
225 | 199 | asgi_scope_client = asgi_scope.get("client") |
226 | 200 | if asgi_scope_client: |
227 | | - if has_data_collection_enabled(client_options): |
228 | | - if client_options["data_collection"]["user_info"]: |
229 | | - ip = _get_ip(asgi_scope) |
230 | | - attributes["client.address"] = ip |
231 | | - elif should_send_default_pii(): |
| 201 | + if client_options["data_collection"]["user_info"]: |
232 | 202 | ip = _get_ip(asgi_scope) |
233 | 203 | attributes["client.address"] = ip |
234 | 204 |
|
|
0 commit comments