Skip to content

Add top level API for add_atttachment. #4360

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

Merged
merged 3 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Capturing Data
Enriching Events
================

.. autofunction:: sentry_sdk.api.add_attachment
.. autofunction:: sentry_sdk.api.add_breadcrumb
.. autofunction:: sentry_sdk.api.set_context
.. autofunction:: sentry_sdk.api.set_extra
Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"integrations",
# From sentry_sdk.api
"init",
"add_attachment",
"add_breadcrumb",
"capture_event",
"capture_exception",
Expand Down
15 changes: 15 additions & 0 deletions sentry_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
# When changing this, update __all__ in __init__.py too
__all__ = [
"init",
"add_attachment",
"add_breadcrumb",
"capture_event",
"capture_exception",
Expand Down Expand Up @@ -171,6 +172,20 @@ def capture_exception(
return get_current_scope().capture_exception(error, scope=scope, **scope_kwargs)


@scopemethod
def add_attachment(
bytes=None, # type: Union[None, bytes, Callable[[], bytes]]
filename=None, # type: Optional[str]
path=None, # type: Optional[str]
content_type=None, # type: Optional[str]
add_to_transactions=False, # type: bool
):
# type: (...) -> None
return get_isolation_scope().add_attachment(
bytes, filename, path, content_type, add_to_transactions
)


@scopemethod
def add_breadcrumb(
crumb=None, # type: Optional[sentry_sdk._types.Breadcrumb]
Expand Down
Loading