|
64 | 64 | from sentry.utils.outcomes import Outcome, track_outcome |
65 | 65 | from sentry.utils.pubsub import QueuedPublisherService, KafkaPublisher |
66 | 66 | from sentry.utils.safe import safe_execute |
| 67 | +from sentry.utils.sdk import configure_scope |
67 | 68 | from sentry.web.helpers import render_to_response |
68 | 69 | from sentry.web.relay_config import get_full_relay_config |
69 | 70 | from sentry.web.client_config import get_client_config |
@@ -130,6 +131,17 @@ def allow_cors_options_wrapper(self, request, *args, **kwargs): |
130 | 131 | return allow_cors_options_wrapper |
131 | 132 |
|
132 | 133 |
|
| 134 | +def disable_transaction_events(): |
| 135 | + """ |
| 136 | + Do not send a transaction event for the current transaction. |
| 137 | +
|
| 138 | + This is used in StoreView to prevent infinite recursion. |
| 139 | + """ |
| 140 | + with configure_scope() as scope: |
| 141 | + if scope.span: |
| 142 | + scope.span.sampled = False |
| 143 | + |
| 144 | + |
133 | 145 | def api(func): |
134 | 146 | @wraps(func) |
135 | 147 | def wrapped(request, *args, **kwargs): |
@@ -327,7 +339,12 @@ def _parse_header(self, request, relay_config): |
327 | 339 | ) |
328 | 340 |
|
329 | 341 | if not auth.client: |
330 | | - track_outcome(relay_config.organization_id, relay_config.project_id, None, Outcome.INVALID, "auth_client") |
| 342 | + track_outcome( |
| 343 | + relay_config.organization_id, |
| 344 | + relay_config.project_id, |
| 345 | + None, |
| 346 | + Outcome.INVALID, |
| 347 | + "auth_client") |
331 | 348 | raise APIError("Client did not send 'client' identifier") |
332 | 349 |
|
333 | 350 | return auth |
@@ -382,7 +399,8 @@ def dispatch(self, request, project_id=None, *args, **kwargs): |
382 | 399 | ) |
383 | 400 |
|
384 | 401 | # if the project id is not directly specified get it from the authentication information |
385 | | - project_id = _get_project_id_from_request(project_id, request, self.auth_helper_cls, helper) |
| 402 | + project_id = _get_project_id_from_request( |
| 403 | + project_id, request, self.auth_helper_cls, helper) |
386 | 404 |
|
387 | 405 | relay_config = get_full_relay_config(project_id) |
388 | 406 |
|
@@ -561,7 +579,9 @@ def pre_normalize(self, data, helper): |
561 | 579 | """Mutate the given EventManager. Hook for subtypes of StoreView (CSP)""" |
562 | 580 | pass |
563 | 581 |
|
564 | | - def process(self, request, project, key, auth, helper, data, relay_config, attachments=None, **kwargs): |
| 582 | + def process(self, request, project, key, auth, helper, |
| 583 | + data, relay_config, attachments=None, **kwargs): |
| 584 | + disable_transaction_events() |
565 | 585 | metrics.incr('events.total', skip_internal=False) |
566 | 586 |
|
567 | 587 | project_id = relay_config.project_id |
@@ -829,7 +849,8 @@ def post(self, request, project, relay_config, **kwargs): |
829 | 849 | )) |
830 | 850 |
|
831 | 851 | # Append all other files as generic attachments. |
832 | | - # RaduW 4 Jun 2019 always sent attachments for minidump (does not use event-attachments feature) |
| 852 | + # RaduW 4 Jun 2019 always sent attachments for minidump (does not use |
| 853 | + # event-attachments feature) |
833 | 854 | for name, file in six.iteritems(request_files): |
834 | 855 | if name == 'upload_file_minidump': |
835 | 856 | continue |
|
0 commit comments