-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(python): Update attachment docs for 2.x
Update attachment docs to reflect new API added in Python SDK 2.0.0, and introduce other general improvements to the page. Depends on getsentry/sentry-python#3342, which adds parameter documentation to the API Docs. Fixes: #10844 Related: getsentry/sentry-python#3340
- Loading branch information
1 parent
c200357
commit ac34c4e
Showing
1 changed file
with
13 additions
and
19 deletions.
There are no files selected for viewing
32 changes: 13 additions & 19 deletions
32
platform-includes/enriching-events/add-attachment/python.mdx
This file contains 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 |
---|---|---|
@@ -1,28 +1,22 @@ | ||
Attachments live on the `Scope` and will be sent with all events. | ||
Attachments live on the [`Scope`](/platforms/python/enriching-events/scopes/). The SDK sends all attachments on a given `Scope` with every non-transaction event captured within the `Scope`. Optionally, an attachment can be sent with all events, including transactions, when the attachment is added with the `add_to_transactions` option set to `True`. | ||
|
||
```python | ||
# Add an attachment | ||
from sentry_sdk import configure_scope | ||
from sentry_sdk import Scope | ||
|
||
with configure_scope() as scope: | ||
scope.add_attachment(bytes=b"Hello World!", filename="attachment.txt") | ||
scope.add_attachment(path="/path/to/attachment/file.txt") | ||
``` | ||
|
||
An attachment has the following fields: | ||
|
||
`path` | ||
# Scope.get_isolation_scope() or Scope.get_global_scope() can also be used. | ||
# Read about the different scopes on our Scope docs page. | ||
scope = Scope.get_current_scope() | ||
|
||
The path to the attachment file. The `filename` and `content_type` will be inferred if not explicitly provided when using this mode. | ||
# Add attachment titled "attachment.txt" with content "Hello World!" | ||
scope.add_attachment(bytes=b"Hello World!", filename="attachment.txt") | ||
|
||
`bytes` | ||
# Attach the file located at /path/to/attachment/file.txt | ||
scope.add_attachment(path="/path/to/attachment/file.txt") | ||
|
||
The content of the attachment as bytes. | ||
|
||
`filename` | ||
|
||
The filename is required if using `bytes` and will be displayed in [sentry.io](https://sentry.io). | ||
# This attachment will also be sent with transactions | ||
scope.add_attachment(path="/other/attachment.txt", add_to_transactions=True) | ||
``` | ||
|
||
`content_type` | ||
|
||
The type of content stored in this attachment. Any [MIME type](https://www.iana.org/assignments/media-types/media-types.xhtml) may be used; the default is `application/octet-stream`. | ||
Our [API Docs](https://getsentry.github.io/sentry-python/apidocs.html#sentry_sdk.Scope.add_attachment) describe the `add_attachment` method's parameters in detail. |