Repository: getsentry/sentry-python

Issue:
Deprecate `sentry_sdk.configure_scope`
Calling this function should emit a `DeprecationWarning`. Add a test to verify this behavior.

Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/getsentry/sentry-python/pull/3351?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 79.78%. Comparing base [(`4aa4c01`)](https://app.codecov.io/gh/getsentry/sentry-python/commit/4aa4c01271940e9e1d554bb1cd452bd54e33ad99?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) to head [(`6ad6b96`)](https://app.codecov.io/gh/getsentry/sentry-python/commit/6ad6b96e280dd3a600ac8faf3101bf8ed5a869d4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry).

:white_check_mark: All tests successful. No failed tests found.

<details><summary>Additional details and impacted files</summary>


```diff
@@                          Coverage Diff                          @@
##           szokeasaurusrex/configure-scope-2    #3351      +/-   ##
=====================================================================
- Coverage                              79.79%   79.78%   -0.02%     
=====================================================================
  Files                                    133      133              
  Lines                                  14319    14321       +2     
  Branches                                3009     3009              
=====================================================================
  Hits                                   11426    11426              
  Misses                                  2071     2071              
- Partials                                 822      824       +2     
```

| [Files](https://app.codecov.io/gh/getsentry/sentry-python/pull/3351?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry) | Coverage Δ | |
|---|---|---|
| [sentry\_sdk/api.py](https://app.codecov.io/gh/getsentry/sentry-python/pull/3351?src=pr&el=tree&filepath=sentry_sdk%2Fapi.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry#diff-c2VudHJ5X3Nkay9hcGkucHk=) | `79.20% <100.00%> (+0.33%)` | :arrow_up: |

... and [2 files with indirect coverage changes](https://app.codecov.io/gh/getsentry/sentry-python/pull/3351/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getsentry)

</details>

Patch:
diff --git a/sentry_sdk/api.py b/sentry_sdk/api.py
index 41c48141..d28dbd92 100644
--- a/sentry_sdk/api.py
+++ b/sentry_sdk/api.py
@@ -1,4 +1,5 @@
 import inspect
+import warnings
 from contextlib import contextmanager
 
 from sentry_sdk import tracing_utils, Client
@@ -185,6 +186,14 @@ def configure_scope(  # noqa: F811
 
     :returns: If no callback is provided, returns a context manager that returns the scope.
     """
+    warnings.warn(
+        "sentry_sdk.configure_scope is deprecated and will be removed in the next major version. "
+        "Please consult our migration guide to learn how to migrate to the new API: "
+        "https://docs.sentry.io/platforms/python/migration/1.x-to-2.x#scope-configuring",
+        DeprecationWarning,
+        stacklevel=2,
+    )
+
     scope = Scope.get_isolation_scope()
     scope.generate_propagation_context()
 


Test patch:
diff --git a/tests/test_api.py b/tests/test_api.py
index a6c44260..1f2a1b78 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -11,6 +11,7 @@ from sentry_sdk import (
     is_initialized,
     start_transaction,
     set_tags,
+    configure_scope,
 )
 
 from sentry_sdk.client import Client, NonRecordingClient
@@ -179,3 +180,9 @@ def test_set_tags(sentry_init, capture_events):
         "tag2": "updated",
         "tag3": "new",
     }, "Updating tags with empty dict changed tags"
+
+
+def test_configure_scope_deprecation():
+    with pytest.warns(DeprecationWarning):
+        with configure_scope():
+            ...
diff --git a/tests/test_client.py b/tests/test_client.py
index 4abf0168..15a140d3 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -570,7 +570,9 @@ def test_atexit(tmpdir, monkeypatch, num_messages):
     assert output.count(b"HI") == num_messages
 
 
-def test_configure_scope_available(sentry_init, request, monkeypatch):
+def test_configure_scope_available(
+    sentry_init, request, monkeypatch, suppress_deprecation_warnings
+):
     """
     Test that scope is configured if client is configured