Skip to content

Commit bd917b6

Browse files
docs(attachment): Document attachment parameters
Document parameters to `sentry_sdk.Scope.add_attachment` and `sentry_sdk.attachments.Attachment`. Fixes: #3340 Related: getsentry/sentry-docs#10844
1 parent 3cd88ec commit bd917b6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

sentry_sdk/attachments.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@
99

1010

1111
class Attachment:
12+
"""Additional files/data to send along with an event.
13+
14+
This class stores attachments that can be sent along with an event. Attachments are files or other data, e.g.
15+
config or log files, that are relevant to an event. Attachments are set on the ``Scope``, and are sent along with
16+
all non-transaction events (or all events including transactions if ``add_to_transactions`` is ``True``) that are
17+
captured within the ``Scope``.
18+
19+
To add an attachment to a ``Scope``, use :py:meth:`sentry_sdk.Scope.add_attachment`. The parameters for
20+
``add_attachment`` are the same as the parameters for this class's constructor.
21+
22+
:param bytes: Raw bytes of the attachment, or a function that returns the raw bytes. Must be provided unless
23+
``path`` is provided.
24+
:param filename: The filename of the attachment. Must be provided unless ``path`` is provided.
25+
:param path: Path to a file to attach. Must be provided unless ``bytes`` is provided.
26+
:param content_type: The content type of the attachment. If not provided, it will be guessed from the ``filename``
27+
parameter, if available, or the ``path`` parameter if ``filename`` is ``None``.
28+
:param add_to_transactions: Whether to add this attachment to transactions. Defaults to ``False``.
29+
"""
30+
1231
def __init__(
1332
self,
1433
bytes=None, # type: Union[None, bytes, Callable[[], bytes]]

sentry_sdk/scope.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,10 @@ def add_attachment(
900900
add_to_transactions=False, # type: bool
901901
):
902902
# type: (...) -> None
903-
"""Adds an attachment to future events sent."""
903+
"""Adds an attachment to future events sent from this scope.
904+
905+
The parameters are the same as for the :py:class:`sentry_sdk.attachments.Attachment` constructor.
906+
"""
904907
self._attachments.append(
905908
Attachment(
906909
bytes=bytes,

0 commit comments

Comments
 (0)