Skip to content
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

Merged
merged 2 commits into from Oct 19, 2020

Conversation

untitaker
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Oct 7, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/sentry/sentry-docs/1xne0k9tn/sentry.dev
✅ Preview: https://sentry-docs-git-ref-no-configure-scope.sentry.dev

Copy link
Contributor

@rhcarvalho rhcarvalho left a 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 👍

@@ -1,10 +1,9 @@
```python
from sentry_sdk import configure_scope
from sentry_sdk import set_context
Copy link
Contributor

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.

Comment on lines 2 to 11
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"})
Copy link
Contributor

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)

Copy link
Member Author

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.

@untitaker untitaker merged commit ff41449 into master Oct 19, 2020
@untitaker untitaker deleted the ref/no-configure-scope branch October 19, 2020 09:55
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants