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.exsconfig :sentry,
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0example-org / example-project"
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
| Type | string | 
|---|---|
| ENV Variable | SENTRY_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
| Type | string | 
|---|---|
| ENV Variable | SENTRY_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
| Type | string | 
|---|---|
| ENV Variable | SENTRY_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
| Type | float | 
|---|---|
| Default | 1.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
| Type | integer | 
|---|---|
| Default | 100 | 
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
| Type | string | 
|---|
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
| Type | function | 
|---|
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
| Type | function | 
|---|
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
| Type | integer | 
|---|---|
| Default | 4 | 
The maximum number of attempts to send an event to Sentry.
client
| Default | Sentry.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
| Type | integer | 
|---|---|
| Default | 50 | 
The maximum number of connections to keep in the pool. Only applied if client is set to Sentry.HackneyClient.
hackney_pool_timeout
| Type | integer | 
|---|---|
| Default | 5000 | 
The maximum time to wait (in milliseconds) for a connection to become available. Only applied if client is set to Sentry.HackneyClient.
traces_sample_rate
| Type | float | 
|---|---|
| Default | nil | 
A number between 0.0 and 1.0 that determines the percentage of transactions that will be sent to Sentry. Either this or traces_sampler must be defined to enable tracing.
config :sentry,
  traces_sample_rate: 0.2  # Sample 20% of transactions
traces_sampler
| Type | function | 
|---|
A function that determines the sample rate for transaction events. This function receives a sampling context map and should return a boolean or a float between 0.0 and 1.0.
config :sentry,
  traces_sampler: fn sampling_context ->
    case sampling_context.transaction_context.op do
      "http.server" -> 0.1  # Sample 10% of HTTP requests
      _ -> 0.05             # Sample 5% of other operations
    end
  end
If both :traces_sampler and :traces_sample_rate are configured, :traces_sampler takes precedence.
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").