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
ref: Rework configure_scope examples in Python #2489
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/sentry/sentry-docs/1xne0k9tn/sentry.dev |
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 lack the context behind this change, but looks good. Removing lots of unnecessary use of configure_scope
👍
src/includes/set-context/python.mdx
Outdated
@@ -1,10 +1,9 @@ | |||
```python | |||
from sentry_sdk import configure_scope | |||
from sentry_sdk import set_context |
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.
These from sentry_sdk import *
examples look non-idiomatic to me. I expect most users to be writing import sentry_sdk
and sentry_sdk.FOO()
instead of bringing parts of the SDK into the global namespace.
from sentry_sdk import configure_scope | ||
import sentry_sdk | ||
|
||
with configure_scope() as scope: | ||
with sentry_sdk.configure_scope() as scope: | ||
scope.set_tag("my-tag", "my value") | ||
scope.user = {'id': 42, 'email': 'john.doe@example.com'} | ||
scope.user = {"id": 42, "email": "john.doe@example.com"} | ||
|
||
# Or: | ||
|
||
sentry_sdk.set_tag("my-tag", "my value") | ||
sentry_sdk.set_user({"id": 42, "email": "john.doe@example.com"}) |
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.
Maybe better examples here would be methods that don't have global helpers:
import logging
import sentry_sdk
with configure_scope() as scope:
scope.clear()
scope.set_level(logging.DEBUG)
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 added clear() but set_level already exists. I think we should strive for exposing more stuff as global api rather than documenting the differences.
No description provided.