Browse Source

Revert "Bump Sentry Python SDK to version 2.0.0a2 (#66397)"

This reverts commit 51ae02e46645b11c7d2463d8ef0bc6c60e542981.

Co-authored-by: antonpirker <202325+antonpirker@users.noreply.github.com>
getsentry-bot 1 year ago
parent
commit
fa7338300d

+ 10 - 10
.github/actions/setup-sentry/action.yml

@@ -81,16 +81,16 @@ runs:
         echo "PYTEST_ADDOPTS=--reruns=5 --durations=10 --fail-slow=60s" >> $GITHUB_ENV
 
         ### pytest-sentry configuration ###
-        # if [ "$GITHUB_REPOSITORY" = "getsentry/sentry" ]; then
-        #   echo "PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079" >> $GITHUB_ENV
-        #   echo "PYTEST_SENTRY_TRACES_SAMPLE_RATE=0" >> $GITHUB_ENV
-
-        #   # This records failures on master to sentry in order to detect flakey tests, as it's
-        #   # expected that people have failing tests on their PRs
-        #   if [ "$GITHUB_REF" = "refs/heads/master" ]; then
-        #     echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV
-        #   fi
-        # fi
+        if [ "$GITHUB_REPOSITORY" = "getsentry/sentry" ]; then
+          echo "PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079" >> $GITHUB_ENV
+          echo "PYTEST_SENTRY_TRACES_SAMPLE_RATE=0" >> $GITHUB_ENV
+
+          # This records failures on master to sentry in order to detect flakey tests, as it's
+          # expected that people have failing tests on their PRs
+          if [ "$GITHUB_REF" = "refs/heads/master" ]; then
+            echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV
+          fi
+        fi
 
         # Configure a different release version, otherwise it defaults to the
         # commit sha which will conflict with our actual prod releases. This is a

+ 1 - 1
requirements-base.txt

@@ -66,7 +66,7 @@ sentry-kafka-schemas>=0.1.58
 sentry-ophio==0.1.5
 sentry-redis-tools>=0.1.7
 sentry-relay>=0.8.45
-sentry-sdk>=2.0.0a2
+sentry-sdk>=1.39.2
 snuba-sdk>=2.0.29
 simplejson>=3.17.6
 sqlparse>=0.4.4

+ 3 - 1
requirements-dev-frozen.txt

@@ -145,6 +145,7 @@ pytest-cov==4.0.0
 pytest-django==4.8.0
 pytest-fail-slow==0.3.0
 pytest-rerunfailures==11.0
+pytest-sentry==0.1.11
 pytest-xdist==3.0.2
 python-dateutil==2.8.2
 python-rapidjson==1.8
@@ -180,7 +181,7 @@ sentry-kafka-schemas==0.1.58
 sentry-ophio==0.1.5
 sentry-redis-tools==0.1.7
 sentry-relay==0.8.45
-sentry-sdk==2.0.0a2
+sentry-sdk==1.39.2
 sentry-usage-accountant==0.0.10
 simplejson==3.17.6
 six==1.16.0
@@ -229,6 +230,7 @@ wcwidth==0.2.10
 websocket-client==1.3.2
 werkzeug==3.0.1
 wheel==0.38.4
+wrapt==1.14.1
 wsproto==1.1.0
 xmlsec==1.3.13
 zstandard==0.18.0

+ 1 - 2
requirements-dev.txt

@@ -12,8 +12,7 @@ pytest-cov>=4.0.0
 pytest-django>=4.8.0
 pytest-fail-slow>=0.3.0
 pytest-rerunfailures>=11
-# Removed because of Python SDK 2.0 (this package does not work with SDK 2.0)
-# pytest-sentry>=0.1.11
+pytest-sentry>=0.1.11
 pytest-xdist>=3
 responses>=0.23.1
 selenium>=4.16.0

+ 1 - 1
requirements-frozen.txt

@@ -123,7 +123,7 @@ sentry-kafka-schemas==0.1.58
 sentry-ophio==0.1.5
 sentry-redis-tools==0.1.7
 sentry-relay==0.8.45
-sentry-sdk==2.0.0a2
+sentry-sdk==1.39.2
 sentry-usage-accountant==0.0.10
 simplejson==3.17.6
 six==1.16.0

+ 1 - 1
src/sentry/auth/helper.py

@@ -134,7 +134,7 @@ class AuthIdentityHandler:
     @staticmethod
     def warn_about_ambiguous_email(email: str, users: Collection[User], chosen_user: User) -> None:
         with sentry_sdk.push_scope() as scope:
-            scope.set_level("warning")
+            scope.level = "warning"
             scope.set_tag("email", email)
             scope.set_extra("user_ids", [user.id for user in users])
             scope.set_extra("chosen_user", chosen_user.id)

+ 6 - 6
src/sentry/cache/base.py

@@ -46,9 +46,9 @@ class BaseCache(local):
         if not self.is_default_cache:
             return
 
-        scope = sentry_sdk.Scope.get_current_scope()
-        # Do not set this tag if we're in the global scope (which roughly
-        # equates to having a transaction).
-        if scope.transaction:
-            sentry_sdk.set_tag(f"{op}_default_cache", "true")
-            sentry_sdk.set_tag("used_default_cache", "true")
+        with sentry_sdk.configure_scope() as scope:
+            # Do not set this tag if we're in the global scope (which roughly
+            # equates to having a transaction).
+            if scope.transaction:
+                scope.set_tag(f"{op}_default_cache", "true")
+                scope.set_tag("used_default_cache", "true")

+ 2 - 2
src/sentry/data_export/tasks.py

@@ -77,7 +77,7 @@ def assemble_download(
         with sentry_sdk.configure_scope() as scope:
             if data_export.user_id:
                 user = dict(id=data_export.user_id)
-                scope.set_user(user)
+                scope.user = user
             scope.set_tag("organization.slug", data_export.organization.slug)
             scope.set_tag("export.type", ExportQueryType.as_str(data_export.query_type))
             scope.set_extra("export.query", data_export.query_info)
@@ -309,7 +309,7 @@ def merge_export_blobs(data_export_id, **kwargs):
         with sentry_sdk.configure_scope() as scope:
             if data_export.user_id:
                 user = dict(id=data_export.user_id)
-                scope.set_user(user)
+                scope.user = user
             scope.set_tag("organization.slug", data_export.organization.slug)
             scope.set_tag("export.type", ExportQueryType.as_str(data_export.query_type))
             scope.set_extra("export.query", data_export.query_info)

+ 1 - 1
src/sentry/scim/endpoints/utils.py

@@ -20,7 +20,7 @@ ACCEPTED_FILTERED_KEYS = ["userName", "value", "displayName"]
 
 class SCIMApiError(APIException):
     def __init__(self, detail, status_code=400):
-        transaction = sentry_sdk.Scope.get_current_scope().transaction
+        transaction = sentry_sdk.Hub.current.scope.transaction
         if transaction is not None:
             transaction.set_tag("http.status_code", status_code)
         self.status_code = status_code

+ 15 - 14
src/sentry/utils/sdk.py

@@ -562,20 +562,21 @@ def check_current_scope_transaction(
     Note: Ignores scope `transaction` values with `source = "custom"`, indicating a value which has
     been set maunually.
     """
-    scope = sentry_sdk.Scope.get_current_scope()
-    transaction_from_request = get_transaction_name_from_request(request)
 
-    if (
-        scope._transaction is not None
-        and scope._transaction != transaction_from_request
-        and scope._transaction_info.get("source") != "custom"
-    ):
-        return {
-            "scope_transaction": scope._transaction,
-            "request_transaction": transaction_from_request,
-        }
-    else:
-        return None
+    with configure_scope() as scope:
+        transaction_from_request = get_transaction_name_from_request(request)
+
+        if (
+            scope._transaction is not None
+            and scope._transaction != transaction_from_request
+            and scope._transaction_info.get("source") != "custom"
+        ):
+            return {
+                "scope_transaction": scope._transaction,
+                "request_transaction": transaction_from_request,
+            }
+        else:
+            return None
 
 
 def capture_exception_with_scope_check(
@@ -673,7 +674,7 @@ def bind_ambiguous_org_context(
 
 def set_measurement(measurement_name, value, unit=None):
     try:
-        transaction = sentry_sdk.Scope.get_current_scope().transaction
+        transaction = sentry_sdk.Hub.current.scope.transaction
         if transaction is not None:
             transaction.set_measurement(measurement_name, value, unit)
     except Exception:

Some files were not shown because too many files changed in this diff