-
Notifications
You must be signed in to change notification settings - Fork 612
docs: Update docs with new Tracing and Scope APIs (#5508) #5712
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
harryautomazione
wants to merge
6
commits into
getsentry:master
from
harryautomazione:docs/update-tracing-api
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0680d18
docs: Document span filtering migration to span first
harryautomazione cd81890
feat(db): Distinguish async vs sync database drivers with db.driver a…
harryautomazione 8c0ea16
fix(asyncpg): add db.driver to connect span and cleanup docs
harryautomazione 397f961
Update docs with new Tracing and Scope APIs (#5508)
harryautomazione 61a0b65
fix: Correct start_child_span to start_span in docs
harryautomazione 7bb6846
refactor: Remove internal function usage in test_pydantic_ai
harryautomazione File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| ======= | ||
| Tracing | ||
| ======= | ||
|
|
||
| With Performance Monitoring, Sentry tracks your software's performance, measuring variables such as throughput and latency. | ||
|
|
||
| Manual Instrumentation | ||
| ===================== | ||
|
|
||
| You can manually start transactions and spans to trace custom operations in your application. | ||
|
|
||
| Transactions | ||
| ------------ | ||
| A transaction represents a single instance of a service being called. It forms the root of a trace tree. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import sentry_sdk | ||
|
|
||
| # Start a transaction as a context manager | ||
| with sentry_sdk.start_transaction(name="process-order"): | ||
| # Your application logic here | ||
| pass | ||
|
|
||
| Spans | ||
| ----- | ||
| Spans represent individual units of work within a transaction, such as a database query or an API call. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import sentry_sdk | ||
|
|
||
| # Start a child span under the current transaction | ||
| with sentry_sdk.start_child_span(op="db.query", name="SELECT * FROM users"): | ||
| # Your operation here | ||
| pass | ||
|
|
||
|
|
||
| Managing Context with Scopes | ||
| ============================ | ||
|
|
||
| Sentry use **Scopes** to manage execution context and event enrichment. In SDK 2.x, top-level APIs replace the deprecated Hub model. | ||
|
|
||
| Isolation Scope | ||
| --------------- | ||
| The `isolation_scope` should be used for isolating data that belongs to a single request or job lifecycle. It propagates data across child scopes. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import sentry_sdk | ||
|
|
||
| with sentry_sdk.isolation_scope() as scope: | ||
| scope.set_tag("user_type", "admin") | ||
| # Operations triggered here will include the tag | ||
|
|
||
| New Scope | ||
| --------- | ||
| The `new_scope` forks the current scope for local, short-lived modifications. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import sentry_sdk | ||
|
|
||
| with sentry_sdk.new_scope() as scope: | ||
| scope.set_extra("temp_debug_data", 123) | ||
| # Changes are discarded when existing the block | ||
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
Oops, something went wrong.
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.