Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 657
(1) Add new scopes related API (but not yet calling it)#2609
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
Closed
Uh oh!
There was an error while loading. Please reload this page.
Closed
Changes from all commits
Commits
Show all changes
97 commits
Select commit
Hold shift + click to select a range
9487038
(1) Move `add_breadcrumb` and session function from Hub to Scope (#2578)
antonpirker a17cb67
Merge branch 'master' into feat/new-scopes
antonpirker b4183bd
Merge branch 'master' into feat/new-scopes
antonpirker eff8f78
(5) Add `reset()` to thread local ContextVar and no-op `copy_context(…
antonpirker 79e15f5
(2) Move `capture_*` from Hub to Client (#2555)
antonpirker 5f332e3
(3) Move tracing related functions from Hub to Scope (#2558)
antonpirker eee394d
Added new API
antonpirker 5816b54
formatting
antonpirker 7a440fe
formatting
antonpirker 0a40f62
formatting
antonpirker ea8f139
Removed duplicated import
antonpirker d9c88e7
formatting
antonpirker 67eea1e
formatting
antonpirker 76d352e
formatting
antonpirker 0feab1a
formatting
antonpirker db610a8
Merge branch 'master' into new-scopes-add-api
antonpirker cabf8d9
Merge branch 'master' into feat/new-scopes
antonpirker 7cc1f86
Merge branch 'feat/new-scopes' into new-scopes-add-api
antonpirker cce06c7
trigger ci
antonpirker 1f06fbb
trigger ci
antonpirker 692a2dc
Merge branch 'new-scopes-add-api' of github.com:getsentry/sentry-pyth…
antonpirker 9d2a7b1
Fixed import
antonpirker c5b8522
Merge branch 'master' into feat/new-scopes
antonpirker 1b17770
Renamed api
antonpirker e034aa9
Renamed scope vars
antonpirker ba74c1e
Made scope.client never None
antonpirker 6a6bcf7
now for real
antonpirker 94ef082
Better naming for scope context and global vars
antonpirker a213490
Merge branch 'master' into feat/new-scopes
antonpirker d2fb4b5
Removed private methods from NoopClient because they should never be …
antonpirker 62889d5
Cleanup and mechanism to prevent recursion
antonpirker f51c691
Cleanup
antonpirker 3eb2243
Improved scope api
antonpirker 553cbbc
Bring back old _merge_scopes
antonpirker b63483c
docs
antonpirker af54208
Added some tests
antonpirker 7366818
Added tests
antonpirker 9ad022b
Apply suggestions from code review
antonpirker 699ef78
Fixing stuff
antonpirker 55a9f4f
Improved Client inheritance
antonpirker 09737e1
Removed useless code
antonpirker 0c47518
Removed useless context copying
antonpirker 01b663a
Fixed import
antonpirker 50afa9d
Added more tests
antonpirker c16be2b
Sorted __all__
antonpirker 9115743
Deletion of thread local vars is not possible in older Python
antonpirker 70b3d99
Fixed deletion of thread local var in Python 3.6+
antonpirker 8eeeed3
Merge branch 'master' into feat/new-scopes
antonpirker 9952097
Merge branch 'feat/new-scopes' into new-scopes-add-api
antonpirker a8f98b2
Merge branch 'master' into new-scopes-add-api
antonpirker 059f051
Fixed docstring
antonpirker b027411
Fixed docstring
antonpirker 8c4fddc
Fixed imports
antonpirker 4d884e9
Back to normal delete of context var.
antonpirker 1c1b911
Delete from the underlying __dict__. This is ok according to the docs.
antonpirker abd7c37
deactivated tests to try something
antonpirker 3420b24
enable one test
antonpirker 668a7a4
Enabled more tests
antonpirker 95302bd
Another two tests
antonpirker c54ca92
one gone again
antonpirker efffd01
and testing the other one
antonpirker 81eea9a
Check first test
antonpirker e957fdb
If this is green now, i am back to square one.
antonpirker f2ee7c4
this is weird
antonpirker 8ed4e34
one more test
antonpirker e73d85c
forking more test
antonpirker 1c96e1f
more forking
antonpirker 753620a
Cleanup
antonpirker 0172098
Made ScopeType an enum
antonpirker f82bb36
Improved test asserts
antonpirker 387f433
Fixed typing
antonpirker 4d747d6
Moved _copy_on_write to other PR. Makes more sense there because we c…
antonpirker cb27c4c
linting
antonpirker 9ae58ee
reformat
antonpirker 7a22de1
Merge branch 'master' into new-scopes-add-api
antonpirker fca14a3
Update test matrix
antonpirker 041e004
updated apidocs
antonpirker 689ad15
Cleanup
antonpirker 47c973e
Merge branch 'master' into new-scopes-add-api
antonpirker d3917e0
formatting
antonpirker 7189e5e
Merge branch 'feature/new-scopes' into new-scopes-add-api
antonpirker f6cb4ef
Update sentry_sdk/scope.py
antonpirker 72365d4
Renamed NoopClient to NonRecordingClient to be more like otel
antonpirker ae39a43
Added some comments
antonpirker f908fe8
Added the right version number
antonpirker 9247623
Added universal lock and use it when changing the global scope
antonpirker 6be5e5f
Added tests for UniversalLock
antonpirker 3b3537f
Made properties of BaseClient actual properties, not class vars
antonpirker 27522d0
Fixed default value
antonpirker a821b93
Do not call async tests in python 2
antonpirker fcb3f68
Make it run in old python
antonpirker 161a1ac
Make it work with old python
antonpirker b7c0db5
Make api consistent
antonpirker 56b266b
Removed useless universal lock, because locking is not the responsibi…
antonpirker f7f8d42
Apply suggestions from code review
antonpirker b57cde6
Prevent infinite recursion by using default options.
antonpirker 90d8d20
Merge branch 'new-scopes-add-api' of github.com:getsentry/sentry-pyth…
antonpirker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -46,10 +46,12 @@ | ||
| from typing import Type | ||
| from typing import Union | ||
| from sentry_sdk._types import Event, Hint | ||
| from sentry_sdk.integrations import Integration | ||
| from sentry_sdk.metrics import MetricsAggregator | ||
| from sentry_sdk.scope import Scope | ||
| from sentry_sdk._types import Event, Hint | ||
| from sentry_sdk.session import Session | ||
| from sentry_sdk.transport import Transport | ||
| _client_init_debug = ContextVar("client_init_debug") | ||
| @@ -151,19 +153,101 @@ def _get_options(*args, **kwargs): | ||
| module_not_found_error = ImportError # type: ignore | ||
| class _Client(object): | ||
| """The client is internally responsible for capturing the events and | ||
| class BaseClient(object): | ||
| """ | ||
| The basic definition of a client that is used for sending data to Sentry. | ||
| .. versionadded:: 2.0.0 | ||
| """ | ||
| def __init__(self, options=None): | ||
| # type: (Optional[Dict[str, Any]]) -> None | ||
| self.options = ( | ||
| options if options is not None else DEFAULT_OPTIONS | ||
| ) # type: Dict[str, Any] | ||
| self.transport = None # type: Optional[Transport] | ||
| self.monitor = None # type: Optional[Monitor] | ||
| self.metrics_aggregator = None # type: Optional[MetricsAggregator] | ||
antonpirker marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| def __getstate__(self, *args, **kwargs): | ||
| # type: (*Any, **Any) -> Any | ||
| return {"options": {}} | ||
| def __setstate__(self, *args, **kwargs): | ||
| # type: (*Any, **Any) -> None | ||
| pass | ||
| @property | ||
| def dsn(self): | ||
| # type: () -> Optional[str] | ||
| return None | ||
| def should_send_default_pii(self): | ||
| # type: () -> bool | ||
| return False | ||
| def is_active(self): | ||
| # type: () -> bool | ||
| """ | ||
| Returns whether the client is active (able to send data to Sentry) | ||
| .. versionadded:: 2.0.0 | ||
| """ | ||
| return False | ||
| def capture_event(self, *args, **kwargs): | ||
| # type: (*Any, **Any) -> Optional[str] | ||
| return None | ||
| def capture_session(self, *args, **kwargs): | ||
| # type: (*Any, **Any) -> None | ||
| return None | ||
| def get_integration(self, *args, **kwargs): | ||
| # type: (*Any, **Any) -> Optional[Integration] | ||
| return None | ||
| def close(self, *args, **kwargs): | ||
| # type: (*Any, **Any) -> None | ||
| return None | ||
| def flush(self, *args, **kwargs): | ||
| # type: (*Any, **Any) -> None | ||
| return None | ||
| def __enter__(self): | ||
| # type: () -> BaseClient | ||
| return self | ||
| def __exit__(self, exc_type, exc_value, tb): | ||
| # type: (Any, Any, Any) -> None | ||
| return None | ||
| class NonRecordingClient(BaseClient): | ||
| """ | ||
| A client that does not send any events to Sentry. This is used as a fallback when the Sentry SDK is not yet initialized. | ||
| .. versionadded:: 2.0.0 | ||
| """ | ||
| pass | ||
| class _Client(BaseClient): | ||
| """ | ||
| The client is internally responsible for capturing the events and | ||
| forwarding them to sentry through the configured transport. It takes | ||
| the client options as keyword arguments and optionally the DSN as first | ||
| argument. | ||
| Alias of :py:class:`Client`. (Was created for better intelisense support) | ||
| Alias of :py:class:`sentry_sdk.Client`. (Was created for better intelisense support) | ||
| """ | ||
| def __init__(self, *args, **kwargs): | ||
| # type: (*Any, **Any) -> None | ||
| self.options = get_options(*args, **kwargs) # type: Dict[str, Any] | ||
| super(_Client, self).__init__(options=get_options(*args, **kwargs)) | ||
| self._init_impl() | ||
| def __getstate__(self): | ||
| @@ -303,6 +387,15 @@ def _capture_envelope(envelope): | ||
| self._setup_instrumentation(self.options.get("functions_to_trace", [])) | ||
| def is_active(self): | ||
| # type: () -> bool | ||
| """ | ||
| Returns whether the client is active (able to send data to Sentry) | ||
| .. versionadded:: 2.0.0 | ||
| """ | ||
| return True | ||
| @property | ||
| def dsn(self): | ||
| # type: () -> Optional[str] | ||
| @@ -569,7 +662,6 @@ def capture_event( | ||
| :param hint: Contains metadata about the event that can be read from `before_send`, such as the original exception object or a HTTP request object. | ||
| :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events. | ||
| The `scope` and `scope_kwargs` parameters are mutually exclusive. | ||
| :returns: An event ID. May be `None` if there is no DSN set or of if the SDK decided to discard the event for other reasons. In such situations setting `debug=True` on `init()` may help. | ||
| """ | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.