Attachments
Learn more about how Sentry can store additional files in the same request as event attachments.
Sentry can enrich your events for further investigation by storing additional files, such as config or log files, as attachments.
You can use a higher-level SDK for platforms with built-in support for native crashes, or generate and upload attachments using the API:
To receive symbolicated stack traces, you have to upload debug information to Sentry. Unless the option to store crash reports is enabled, Sentry will use the crash reports only to create the event, then will drop the files. For more information, see Debug Information Files.
To add an attachment, you can either configure it when initializing the SDK, or manipulate the list of attachments in the scope.
Adding attachments to the options during SDK initialization will monitor the file and upload it along with any event or crash that is sent to Sentry:
sentry_options_add_attachment(options, "/var/server.log");
Adding attachments to the global scope at run-time after SDK initialization will monitor the file and upload it along with any event or crash that is sent to Sentry, whereas adding attachments to a local scope will only upload the file with the specific event captured in that local scope.
// Global Scope
sentry_attach_file("/var/global.log");
// Local Scope
sentry_scope_t *scope = sentry_local_scope_new();
sentry_scope_attach_file(scope, "/var/local.log");
sentry_value_t event = sentry_value_new_event();
/* ... */
sentry_capture_event_with_scope(event, scope);
crashpad
backend on macOS, the list of attachments that will be added at the time of a hard crash will be frozen at the time of sentry_init
, and later modifications will not be reflected.To remove attachments from the global scope, you can use the sentry_attachment_t
handle returned by sentry_attach_file
. After removing the attachment, the file will no longer be uploaded with any future events or crashes and the handle becomes invalid.
sentry_attachment_t *attachment = sentry_attach_file("/var/temp.log");
/* ... */
sentry_remove_attachment(attachment);
Sentry allows at most 20MB for a compressed request, and at most 100MB of uncompressed attachments per event, including the crash report file (if applicable). Uploads exceeding this size are rejected with HTTP error 413 Payload Too Large
and the data is dropped immediately. To add larger or more files, consider secondary storage options.
Usually, native crash reports range from a few kilobytes to a few megabytes. This leaves sufficient space to add custom attachments. In case your application generates particularly large crash reports, consider to limit or avoid adding additional attachments in the SDK.
Attachments persist for 30 days; if your total storage included in your quota is exceeded, attachments will not be stored. You can delete attachments or their containing events at any time. Deleting an attachment does not affect your quota - Sentry counts an attachment toward your quota as soon as it is stored.
Learn more about how attachments impact your quota.
To limit access to attachments, navigate to your organization's General Settings, then select the Attachments Access dropdown to set appropriate access — any member of your organization, the organization billing owner, member, admin, manager, or owner.
By default, access is granted to all members when storage is enabled. If a member does not have access to the project, the ability to download an attachment is not available; the button will be greyed out in Sentry. The member may only view that an attachment is stored.
Minidumps may contain sensitive information about the target system, such as environment variables, local pathnames, or in-memory representations of input fields, including passwords. By default, Sentry only uses minidump files to create events and immediately drops them. All sensitive information is stripped from the resulting events.
All attachments types, including log files, screenshots and minidumps (if you enable Store Minidumps As Attachments), are stored for 30 days when sent to Sentry. Note that Sentry does not apply data scrubbing to attachments.
You can enable Store Minidumps As Attachments in your organization or project settings under Security & Privacy. By default, this setting is disabled. Determine the maximum number of crash reports that will be stored per issue; disabled, unlimited, or maximum per issue:
If you set a limit per issue, as in the example above, a limit of 5, Sentry will store the first 5 attachments associated with this issue, but drop any that follow. To make room for additional attachments, delete them. Sentry will then accept attachments until the limit is reached again.
Attachments display on the bottom of the Issue Details page for the event that is shown.
Alternately, attachments also appear in the Attachments tab on the Issue Details page, where you can view the Type of attachment, as well as associated events. Click the Event ID to open the Issue Details of that specific event.
If you chose to limit the number of crash reports per issue, you can show Only Crash Reports. This removes all other attachments from the list, which can be useful if the issue has accumulated a large number of events.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").