Basic Options

Learn more about how to configure the SDK. These options are set when the SDK is first initialized, passed to the init function as an object.

SDKs are configurable using a variety of options. The options are largely standardized among SDKs, but there are some differences to better accommodate platform peculiarities. Options are set when the SDK is first initialized.

In Elixir, configuration is handled using the standard Elixir configuration (Config).

Add configuration to the :sentry application in the your config file.

config/prod.exs
Copied
config :sentry,
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0"

We recommend only enabling Sentry in production, so this configuration should go in config/prod.exs in a standard application structure.

The list of common options across SDKs. These work more or less the same in all SDKs, but some subtle differences will exist to better support the platform. Options that can be read from an environment variable (SENTRY_DSN, SENTRY_ENVIRONMENT, SENTRY_RELEASE) are read automatically.

dsn

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.

In runtimes without a process environment (such as the browser) that fallback does not apply.

Learn more about DSN utilization.

release

Sets the release. Some SDKs will try to automatically configure a release out of the box but it's a better idea to manually set it to guarantee that the release is in sync with your deploy integrations or source map uploads. 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 (in the browser SDK, this will be read off of the window.SENTRY_RELEASE.id if available).

environment

Sets the environment. This string is freeform and not 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 (except for the browser SDK where this is not applicable).

sample_rate

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 are sent. If set to 0.1 only 10% of error events will be sent. Events are picked randomly.

max_breadcrumbs

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.

server_name

This option can be used to supply a "server name." When provided, the name of the server is sent along and persisted in the event. For many integrations, the server name actually corresponds to the device hostname, even in situations where the machine is not actually a server.

Most SDKs will attempt to auto-discover this value.

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

before_send

This function is called with an SDK-specific message or error event object, and can return a modified event object, or null to skip reporting the event. This 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.

after_send_event

This function is called with an event and the result of sending that event. This is useful to log send results, instrument Sentry calls, and so on.

Transports are used to send events to Sentry. Transports can be customized to some degree to better support highly specific deployments.

send_result

Controls whether to report events to Sentry synchronously (if set to :sync) or asynchronously (if set to :none). Defaults to :none.

send_max_attempts

The maximum number of attempts to send an event to Sentry. Defaults to 4.

client

The HTTP client to use for sending events to Sentry. This must be a module that implements the Sentry.HTTPClient behaviour. Defaults to Sentry.HackneyClient, which is based on the Hackney HTTP client.

hackney_opts

Options to be passed to Hackney. Only applied if client is set to Sentry.HackneyClient. Defaults to [pool: :sentry_pool].

hackney_pool_max_connections

The maximum number of connections to keep in the pool. Only applied if client is set to Sentry.HackneyClient. Defaults to 50.

hackney_pool_timeout

The maximum time to wait (in milliseconds) for a connection to become available. Only applied if client is set to Sentry.HackneyClient. Defaults to 5000.

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").