Options

Learn more about how the SDK can be configured via options. These are being passed to the init function and therefore 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.

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

    dsn

    Typestring
    ENV VariableSENTRY_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.

    Learn more about DSN utilization.

    release

    Typestring
    ENV VariableSENTRY_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.

    environment

    Typestring
    ENV VariableSENTRY_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.

    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

    Typeinteger
    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.

    server_name

    Typestring

    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

    Typefunction

    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

    Typefunction

    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

    Default:none

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

    send_max_attempts

    Typeinteger
    Default4

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

    client

    DefaultSentry.HackneyClient

    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

    Default[pool: :sentry_pool]

    Options to be passed to Hackney. Only applied if client is set to Sentry.HackneyClient.

    hackney_pool_max_connections

    Typeinteger
    Default50

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

    hackney_pool_timeout

    Typeinteger
    Default5000

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

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