Options for Google Breakpad

Learn more about how the Sentry Native SDK can be configured via options. These are being passed to the init function and therefore set when the SDK is first initialized.

Options are passed into sentry_init as a pointer to an options object created via sentry_options_new(). There are functions that allow to set all options individually.

Copied
#include <sentry.h>

int main(void) {
  sentry_options_t *options = sentry_options_new();
  sentry_options_set_dsn(options, "___PUBLIC_DSN___");
  sentry_options_set_release(options, "my-project-name@2.3.12");
  sentry_options_set_debug(options, 1);
  sentry_init(options);

  /* ... */
}

    Options that can be read from an environment variable (SENTRY_DSN, SENTRY_ENVIRONMENT, SENTRY_RELEASE) are read automatically.

    dsn

    Typestring

    The DSN tells the SDK where to send the events. If this value is not provided, the SDK will try to read it from the SENTRY_DSN environment variable. If that variable also does not exist, the SDK will just not send any events.

    Learn more about DSN utilization.

    database_path

    Typestring
    Default.sentry-native

    Allows you to specify a path to the local event- and crash-database of the Native SDK. This path will default to .sentry-native relative to the current working directory (CWD). While this is a convenient setting for development, we strongly urge you to provide an explicit database path for our production deployments. In many deployment scenarios, the path relative to the CWD will not be writable. For this reason, you should store the database in your application's user-specific data/cache directory (e.g., under %AppData%\Local on Windows, ~/Library/Application Support on macOS, or XDG_CACHE_HOME on Linux).

    debug

    Typebool
    Defaultfalse

    Turns debug mode on or off. If debug is enabled, the SDK will attempt to print out useful debugging information if something goes wrong. If you run a debug-build (NDEBUG isn't defined), it will default to true; otherwise, the default is always false. You can provide a SENTRY_DEBUG environment variable with either "0" or "1" for "off" and "on" respectively, which will override the defaults. It's generally not recommended to turn it on in production, though turning debug mode on will not cause any safety concerns. You can limit the output by setting logger_level to an appropriate level for your production use case.

    logger_level

    Typesentry_level_t
    DefaultSENTRY_LEVEL_DEBUG

    Sets the minimum level of the debug messages the SDK logs. Has no effect unless debug is enabled.

    logger

    Typefunction

    This function is called with the level, the format string, and the arguments of each debug message, and replaces the default logger, which prints to stderr or, on Android, to logcat. It's only called when debug is enabled. Multiple threads may call it concurrently.

    logger_enabled_when_crashed

    Available since0.11.0
    Typebool
    Defaulttrue (false for breakpad on macOS)

    Whether the SDK keeps calling the logger after it detects a crash. Disabling it avoids potential issues that logging might cause during crash handling.

    release

    Typestring

    Sets the release. Release names are strings, but some formats are detected by Sentry and might be rendered differently. Learn more about how to send release data so Sentry can tell you about regressions between releases and identify the potential source in the releases documentation or the sandbox.

    By default the SDK will try to read this value from the SENTRY_RELEASE environment variable.

    environment

    Typestring
    Defaultproduction

    Sets the environment. This string is freeform and set by default. A release can be associated with more than one environment to separate them in the UI (think staging vs prod or similar).

    By default the SDK will try to read this value from the SENTRY_ENVIRONMENT environment variable. Otherwise, the default environment is production.

    dist

    Typestring

    Sets the distribution of the application. Distributions are used to disambiguate build or deployment variants of the same release of an application.

    sample_rate

    Typefloat
    Default1.0

    Configures the sample rate for error events, in the range of 0.0 to 1.0. The default is 1.0, which means that 100% of error events will be sent. If set to 0.1, only 10% of error events will be sent. Events are picked randomly.

    max_breadcrumbs

    Typeint
    Default100

    This variable controls the total amount of breadcrumbs that should be captured. This defaults to 100, but you can set this to any number. However, you should be aware that Sentry has a maximum payload size and any events exceeding that payload size will be dropped.

    send_client_reports

    Available since0.13.6
    Typebool
    Defaulttrue

    Set this boolean to false to disable client reports. Client reports are a protocol feature that allows clients to send status information about themselves to Sentry. They’re currently used mainly to report outcomes for events that were never sent.

    Typebool
    Defaultfalse

    Disables uploads until the user has given consent to the SDK. Give consent with sentry_user_consent_give and revoke it with sentry_user_consent_revoke. The SDK discards envelopes captured before consent is given, unless offline caching or HTTP retry is enabled.

    attach_stacktrace

    Available since0.17.4
    Typebool
    Defaultfalse

    Attaches the stack trace of the capturing thread to events that carry none, such as messages. Events that already carry a stack trace, including crashes, are left untouched. With a stack trace, messages group by call site rather than by message text.

    shutdown_timeout

    Typeuint64_t
    Default2000 (milliseconds)

    Sets the maximum time, in milliseconds, that sentry_close() waits for asynchronous tasks, such as pending uploads, to finish before it attempts a forced termination.

    logs_with_attributes

    Typebool
    Defaultfalse

    Whether calls to sentry_log_X() expect an attributes object as the second argument, allowing users to pass in custom log attributes. An example can be found on the Logs page.

    These options can be used to hook the SDK in various ways to customize the reporting of events.

    before_send

    Typefunction

    This function is called with an SDK-specific message or error event object and a hint, and can return a modified event object, or sentry_value_new_null() to skip reporting the event. To drop it, you must call sentry_value_decref(event) before returning. This hook can be used, for instance, for manual PII stripping before sending.

    By the time before_send is executed, all scope data has already been applied to the event. Further modification of the scope won't have any effect.

    on_crash

    Typefunction

    This function is called with a backend-specific event object and a hint, and can return a modified event object, or sentry_value_new_null() to skip reporting the event. To drop it, you must call sentry_value_decref(event) before returning. In contrast to before_send, it is only called when a crash occurred. You can find detailed information concerning its usage in Filtering.

    before_transaction

    Typefunction

    This function is called with an SDK-specific transaction event object, and can return a modified transaction event object, or sentry_value_new_null() to skip reporting the event. To drop it, you must call sentry_value_decref(tx) before returning. One way this might be used is for manual PII stripping before sending.

    before_send_feedback

    Available since0.16.2
    Typefunction

    This function is called with a feedback event and a hint, and can return a modified event, or sentry_value_new_null() to drop the feedback. The feedback itself is nested under the event's contexts.feedback. To drop it, you must call sentry_value_decref(event) before returning. Use the hint to add attachments.

    User feedback does not go through before_send, so this is the only hook that sees it. See Filtering.

    before_send_log

    Typefunction

    This function is called with an SDK-specific log object, and can return a modified log object, or sentry_value_new_null() to drop the log. In that case, you must call sentry_value_decref(log) before returning.

    before_send_metric

    Available since0.12.6
    Typefunction

    This function is called with an SDK-specific metric object, and can return a modified metric object, or sentry_value_new_null() to drop the metric. In that case, you must call sentry_value_decref(metric) before returning. An example can be found on the Metrics page.

    before_breadcrumb

    Available since0.13.0
    Typefunction

    This function is called with each breadcrumb passed to sentry_add_breadcrumb(), and can return a modified breadcrumb, or sentry_value_new_null() to drop it. To drop it, you must call sentry_value_decref(breadcrumb) before returning.

    before_screenshot

    Available since0.13.7
    Typefunction

    This function is called with the event before a screenshot is captured for it, and should return non-zero to capture the screenshot or zero to skip it. It doesn't take ownership of the event. It's only called on Windows when screenshots are enabled, and isn't supported by the crashpad backend.

    on_crashed_last_run

    Available since0.16.4
    Typefunction

    This function is called during sentry_init() for every envelope of a crash from a previous run. It doesn't take ownership of the envelope, which is only valid during the call. Because sentry_init() hasn't completed yet, the function must not call SDK functions that require an initialized SDK. With the native backend, the option must also be set in the run that crashed, so that the crash daemon keeps the envelope for the next launch.

    initial_scope

    Available since0.16.7
    Typefunction

    This function is called once during sentry_init() with the global scope, before the crash backend starts, so the data it sets is available to crash reports, including those of out-of-process crash handlers. Configure the scope with the sentry_scope_* functions rather than global functions such as sentry_set_tag.

    symbolize_stacktraces

    Typebool
    Defaultfalse (true with the native backend, and on Android, AIX, and PlayStation)

    Enables client-side symbolication of stack traces. This is useful for resolving system library frames when debug information files can't be provided for server-side symbolication. It can have a performance impact, because symbolication runs in the application process when the inproc backend handles a crash, or when you capture an event with any backend.

    system_crash_reporter_enabled

    Typebool
    Defaultfalse

    Forwards crashes to the macOS system crash reporter. Depending on the crash, this may increase the time it takes to handle it. This setting only affects the crashpad and native backends on macOS.

    max_stack_capture_size

    Available since0.17.2
    Typeuint32_t
    Default0 (bytes, no limit)

    Limits the size of the stack captured for each non-crashing thread. The crashed thread is not limited. Set to 0 for no limit. This setting only affects the crashpad and native backends on Linux.

    handler_strategy

    Typesentry_handler_strategy_t
    DefaultSENTRY_HANDLER_STRATEGY_DEFAULT

    Controls when the SDK invokes a previously installed signal handler. By default, it's invoked after the SDK has handled the signal. SENTRY_HANDLER_STRATEGY_CHAIN_AT_START invokes it first instead, which is needed for runtimes like CLR or Mono that convert some signals into managed exceptions. Otherwise, the SDK would report a native crash in addition to the managed exception. This setting only affects the inproc backend on Linux and Android, and the native backend on Linux.

    crash_memory_reserve

    Available since0.17.6
    Typesize_t
    Default0 (bytes, disabled)

    Sets the amount of memory, in bytes, that the SDK reserves during sentry_init() and releases when it handles a crash, so the crash handler can still allocate after the application has run out of memory. Set to 0 to disable it. The default comes from the SENTRY_CRASH_MEMORY_RESERVE CMake option, which is set in KiB.

    These options only affect the native backend.

    crash_reporting_mode

    Available since0.13.2
    Typesentry_crash_reporting_mode_t
    DefaultSENTRY_CRASH_REPORTING_MODE_NATIVE_WITH_MINIDUMP

    Controls which crash report format the native backend sends when the application crashes. This setting only affects the native backend. See Crash Reporting Modes.

    minidump_mode

    Available since0.13.2
    Typesentry_minidump_mode_t
    DefaultSENTRY_MINIDUMP_MODE_SMART

    Controls how much memory the native backend captures in minidumps. This setting only affects the native backend and crash reporting modes that send a minidump. See Minidump Capture Modes.

    thread_stackwalk_mode

    Available since0.16.5
    Typesentry_thread_stackwalk_mode_t
    DefaultSENTRY_THREAD_STACKWALK_MODE_ALL

    Controls which threads the native backend walks when it unwinds stacks on the client. With SENTRY_THREAD_STACKWALK_MODE_CRASHED_ONLY, only the crashed thread gets a stack trace, and the remaining threads are listed with their ID and name. This shortens crash processing for applications with many threads. This setting only affects the native backend and crash reporting modes with client-side stack walking.

    crash_upload_mode

    Available since0.15.0
    Typesentry_crash_upload_mode_t
    DefaultSENTRY_CRASH_UPLOAD_MODE_SYNC

    Controls whether the crashed application waits for the native backend's crash daemon to finish uploading. With SENTRY_CRASH_UPLOAD_MODE_ASYNC, the application can exit as soon as the crash data has been captured, while the daemon continues the upload in the background. This setting only affects the native backend.

    minidump_flags

    Available since0.16.0
    Typesentry_minidump_flags_t

    Sets the raw Windows MINIDUMP_TYPE flags for minidumps. When set, these flags take precedence over minidump_mode. Unsupported bits are discarded, and 0 selects MiniDumpNormal. This setting only affects the native backend on Windows.

    These options only affect the crashpad backend.

    crashpad_wait_for_upload

    Typebool
    Defaultfalse

    Whether Crashpad should delay application shutdown until the upload of the crash report in the crashpad_handler is complete. This is useful for deployment in Docker (Linux and Windows containers) or systemd, where the life cycle of all processes is bound by the root process (typically the application being monitored).

    crashpad_limit_stack_capture_to_sp

    Available since0.12.0
    Typebool
    Defaultfalse

    Uses the current stack pointer to bound the stack capture of the crashpad backend, instead of the full stack region derived from the thread environment block (TEB). This is useful when running under Wine or Proton, where incorrect TEB values can lead to excessively large stack captures. This setting only affects the crashpad backend on Windows.

    traces_sample_rate

    Typefloat
    Default0.0

    A number between 0.0 and 1.0, controlling the percentage chance a given transaction will be sent to Sentry. (0.0 represents 0% while 1.0 represents 100%.) Applies equally to all transactions created in the app. Either this or traces_sampler must be defined to enable tracing.

    traces_sampler

    Typefunction

    A function responsible for determining the percentage chance a given transaction will be sent to Sentry. It will automatically be passed information about the transaction and the context in which it's being created, and must return a number between 0 (0% chance of being sent) and 1 (100% chance of being sent). Can also be used for filtering transactions, by returning 0 for those that are unwanted. Either this or traces_sample_rate must be defined to enable tracing. An example can be found in the Sampling section.

    max_spans

    Typesize_t
    Default1000

    Sets the maximum number of spans that can be attached to a transaction.

    propagate_traceparent

    Available since0.11.3
    Typebool
    Defaultfalse

    Controls whether the SDK should propagate the W3C traceparent HTTP header alongside the sentry-trace header for distributed tracing.

    If your backend uses an OTel collector with tail-based sampling, see Sentry with OTel for an important interaction with this option.

    strict_trace_continuation

    Available since0.14.1
    Typebool
    Defaultfalse

    Controls whether to continue an incoming trace when only one of the trace and the SDK has an organization ID. When enabled, the SDK starts a new trace in that case. When disabled, it continues the incoming trace. If both organization IDs are present and differ, the SDK never continues the trace. See strict trace continuation.

    org_id

    Available since0.14.1
    Typestring

    Overrides the organization ID that the SDK derives from the DSN host, such as 123456 from o123456.ingest.sentry.io. This is typically only needed for self-hosted setups where the DSN host doesn't contain the organization ID.

    These options control in-process app-hang detection. See the App Hangs page for a full explanation and usage example.

    enable_app_hang_tracking

    Available since0.15.2
    Typebool
    Defaultfalse

    Enables or disables in-process app-hang detection. When enabled, a background watchdog thread monitors heartbeats from the watched thread. If no heartbeat is received within app_hang_timeout, an app-hang event is captured and sent to Sentry.

    Must be combined with regular calls to sentry_app_hang_heartbeat() from the thread you want monitored. The first heartbeat latches the calling thread as the monitored thread; heartbeats from any other thread are ignored. To pause detection while the thread stops sending heartbeats on purpose, call sentry_app_hang_pause() (available since 0.16.1).

    app_hang_timeout

    Available since0.15.2
    Typeuint64_t
    Default5000 (milliseconds)

    Sets the app-hang detection timeout, in milliseconds. If enable_app_hang_tracking is enabled and no heartbeat is received from the monitored thread within this window, an app-hang event is captured. The minimum is 1000 ms; the SDK raises lower values, including 0, to 1000 ms.

    These options control how the HTTP transport retries and caches envelopes. See the Transports page for a full explanation and usage example.

    http_retry

    Available since0.13.5
    Typebool
    Defaultfalse

    Enables or disables HTTP retry with exponential backoff for network failures. See Retrying Failed Uploads.

    cache_keep

    Available since0.12.7
    Typesentry_cache_keep_t
    DefaultSENTRY_CACHE_KEEP_NONE

    Controls if and when the SDK keeps envelopes in a persistent cache, in the cache/ subdirectory of the database path. See Offline Caching.

    cache_max_items

    Available since0.12.7
    Typesize_t
    Default30

    Sets the maximum number of items in the cache directory. On startup, the SDK removes cached entries from oldest to newest until the directory contains at most the specified number of items. Set to 0 for no limit. See Offline Caching.

    cache_max_size

    Available since0.12.7
    Typesize_t
    Default0 (bytes, no limit)

    Sets the maximum size in bytes for the cache directory. On startup, the SDK removes cached entries from oldest to newest until the directory size is within the limit. Set to 0 for no limit. See Offline Caching.

    cache_max_age

    Available since0.12.7
    Typetime_t
    Default0 (seconds, no limit)

    Sets the maximum age in seconds for entries in the cache directory. On startup, the SDK removes cached entries exceeding the limit. Set to 0 for no limit. See Offline Caching.

    transfer_timeout

    Available since0.15.0
    Typeuint64_t
    Default0 (milliseconds, no limit)

    Sets the timeout in milliseconds for HTTP transfers. With curl, it limits the total time a request may take. With WinHTTP, it applies to individual send and receive operations. Set to 0 for no limit. Crashpad's crash report upload doesn't support it.

    ca_certs

    Typestring

    Sets the path to a file containing the SSL certificates used for verification. Only the curl transport uses this option.

    enable_large_attachments

    Available since0.13.9
    Typebool
    Defaultfalse

    Uploads attachments above an internal size threshold in a separate request before the envelope is sent, instead of embedding them in the envelope. Without it, Sentry rejects oversized uploads. This requires the projects:relay-upload-endpoint server-side feature.

    Was this helpful?
    Help improve this content
    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").