Skip to content

feat(scope): Remove client parameter #4449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh
- `sentry_sdk.start_transaction`/`sentry_sdk.start_span` no longer takes the following arguments: `span`, `parent_sampled`, `trace_id`, `span_id` or `parent_span_id`.
- You can no longer change the sampled status of a span with `span.sampled = False` after starting it.
- The `Span()` constructor does not accept a `hub` parameter anymore.
- The `sentry_sdk.Scope()` constructor no longer accepts a `client` parameter.
- `Span.finish()` does not accept a `hub` parameter anymore.
- `Span.finish()` no longer returns the `event_id` if the event is sent to sentry.
- The `Profile()` constructor does not accept a `hub` parameter anymore.
Expand All @@ -31,6 +32,7 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh
- The integration for Python `logging` module does not send Sentry issues by default anymore when calling `logging.error()`, `logging.critical()` or `logging.exception()`. If you want to preserve the old behavior use `sentry_sdk.init(integrations=[LoggingIntegration(event_level="ERROR")])`.
- The `SentrySpanProcessor` and `SentryPropagator` are exported from `sentry_sdk.opentelemetry` instead of `sentry_sdk.integrations.opentelemetry`.
- The integration-specific content of the `sampling_context` argument of `traces_sampler` and `profiles_sampler` now looks different.

- The Celery integration doesn't add the `celery_job` dictionary anymore. Instead, the individual keys are now available as:

| Dictionary keys | Sampling context key | Example |
Expand Down Expand Up @@ -133,7 +135,6 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh
| `gcp_event.query_string` | `url.query` |
| `gcp_event.headers` | `http.request.header.{header}` |


### Removed

- Dropped support for Python 3.6.
Expand Down
7 changes: 2 additions & 5 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ class Scope:
"_flags",
)

def __init__(self, ty=None, client=None):
# type: (Optional[ScopeType], Optional[sentry_sdk.Client]) -> None
def __init__(self, ty=None):
# type: (Optional[ScopeType]) -> None
self._type = ty

self._event_processors = [] # type: List[EventProcessor]
Expand All @@ -185,9 +185,6 @@ def __init__(self, ty=None, client=None):

self.client = NonRecordingClient() # type: sentry_sdk.client.BaseClient

if client is not None:
self.set_client(client)

self.clear()

incoming_trace_information = self._load_trace_data_from_env()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def test_scope_client():
assert scope.client.__class__ == NonRecordingClient

custom_client = Client()
scope = Scope(ty="test_more", client=custom_client)
scope = Scope(ty="test_more")
scope.set_client(custom_client)
assert scope._type == "test_more"
assert scope.client is not None
assert scope.client.__class__ == Client
Expand Down
Loading