-
Notifications
You must be signed in to change notification settings - Fork 550
Global scope setters #540
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
Global scope setters #540
Conversation
…) update Hub.push_scope() to allow it to act as both a contentmanager and a decorator, (api.py, utils.py) add new scopemethod api methods {set_tag, set_extra, set_user, set_level} that allow for updating of the current scope
…ator inherit from contextlib.ContextDecorator
…corator with _ScopeManager
…tDecorator compat issue, (sentry_sdk/api.py) update typing to match that of Hub.push_scope()
…(tests/test_basics.py) remove unneeded test_scope_leaks_cleaned_up()
…(sentry_sdk/_compat.py) satisfy linters
…() 'as a decorator' code
…yle in rest of file
Codecov Report
@@ Coverage Diff @@
## master #540 +/- ##
=========================================
- Coverage 85.83% 84.63% -1.2%
=========================================
Files 107 107
Lines 8766 8801 +35
Branches 899 904 +5
=========================================
- Hits 7524 7449 -75
- Misses 921 1032 +111
+ Partials 321 320 -1
Continue to review full report at Codecov.
|
@@ -483,8 +489,6 @@ def push_scope( # noqa | |||
|
|||
return _ScopeManager(self) | |||
|
|||
scope = push_scope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine btw. We never documented this method
Thanks! |
Of course! And this looks like it will work well with #530. Once that PR is merged, the global set_extras and set_tags methods can be created. |
This merge would allow the current scope's level, user, tags, context, and extras to be modified at the global scope.
NOTE: This is a follow-up to pull-request #523 which attempted to allow push_scope() to function as a decorator.