|
21 | 21 | from sentry_sdk.integrations.logging import ignore_logger_for_events |
22 | 22 | from sentry_sdk.scope import Scope, should_send_default_pii |
23 | 23 | from sentry_sdk.sessions import track_session |
24 | | -from sentry_sdk.traces import ( |
25 | | - SOURCE_FOR_STYLE as SEGMENT_SOURCE_FOR_STYLE, |
26 | | -) |
27 | 24 | from sentry_sdk.traces import ( |
28 | 25 | NoOpStreamedSpan, |
29 | 26 | SegmentNameSource, |
@@ -329,21 +326,11 @@ async def sentry_urldispatcher_resolve( |
329 | 326 | pass |
330 | 327 |
|
331 | 328 | if name is not None: |
332 | | - current_span = sentry_sdk.get_current_span() |
333 | | - if isinstance(current_span, StreamedSpan) and not isinstance( |
334 | | - current_span, NoOpStreamedSpan |
335 | | - ): |
336 | | - current_span._segment.name = name |
337 | | - current_span._segment.set_attribute( |
338 | | - "sentry.segment.name.source", |
339 | | - SEGMENT_SOURCE_FOR_STYLE[integration.transaction_style].value, |
340 | | - ) |
341 | | - else: |
342 | | - current_scope = sentry_sdk.get_current_scope() |
343 | | - current_scope.set_transaction_name( |
344 | | - name, |
345 | | - source=SOURCE_FOR_STYLE[integration.transaction_style], |
346 | | - ) |
| 329 | + current_scope = sentry_sdk.get_current_scope() |
| 330 | + current_scope.set_transaction_name( |
| 331 | + name, |
| 332 | + source=SOURCE_FOR_STYLE[integration.transaction_style], |
| 333 | + ) |
347 | 334 |
|
348 | 335 | return rv |
349 | 336 |
|
@@ -554,9 +541,30 @@ def aiohttp_processor( |
554 | 541 | request.path, |
555 | 542 | ) |
556 | 543 |
|
557 | | - request_info["query_string"] = request.query_string |
| 544 | + if has_data_collection_enabled(client_options): |
| 545 | + if request.query_string: |
| 546 | + filtered_query_string = ( |
| 547 | + _apply_data_collection_filtering_to_query_string( |
| 548 | + query_string=request.query_string, |
| 549 | + behaviour=client_options["data_collection"][ |
| 550 | + "url_query_params" |
| 551 | + ], |
| 552 | + ) |
| 553 | + ) |
| 554 | + if filtered_query_string: |
| 555 | + request_info["query_string"] = filtered_query_string |
| 556 | + else: |
| 557 | + request_info["query_string"] = request.query_string |
| 558 | + |
558 | 559 | request_info["method"] = request.method |
559 | | - request_info["env"] = {"REMOTE_ADDR": request.remote} |
| 560 | + |
| 561 | + # REMOTE_ADDR was unconditionally set pre-data collection, so it |
| 562 | + # continues to be set when data collection is not enabled. |
| 563 | + if ( |
| 564 | + not has_data_collection_enabled(client_options) |
| 565 | + or client_options["data_collection"]["user_info"] |
| 566 | + ): |
| 567 | + request_info["env"] = {"REMOTE_ADDR": request.remote} |
560 | 568 | request_info["headers"] = _filter_headers(dict(request.headers)) |
561 | 569 |
|
562 | 570 | # Just attach raw data here if it is within bounds, if available. |
|
0 commit comments