This is the official Sentry SDK for Elixir. It captures errors, monitors cron jobs, and supports distributed tracing via OpenTelemetry integration. The SDK is built as an OTP application with pluggable HTTP clients, logger integration, and framework support for Plug and Phoenix.
| Path | Description |
|---|---|
lib/sentry.ex |
Main public API (capture_exception, capture_message) |
lib/sentry/application.ex |
OTP Application supervisor |
lib/sentry/client.ex |
Event creation, sampling, and callbacks |
lib/sentry/config.ex |
Configuration validation and persistence |
lib/sentry/transport.ex |
HTTP transport abstraction |
lib/sentry/transport/ |
Sender pool, rate limiter |
lib/sentry/telemetry/ |
Ring buffers, scheduler, queue worker |
lib/sentry/telemetry_processor.ex |
Supervisor for buffered event processing |
lib/sentry/opentelemetry/ |
OpenTelemetry span processor, sampler, propagator |
lib/sentry/integrations/ |
Oban, Quantum, Telemetry integrations |
lib/sentry/logger_handler.ex |
Erlang logger handler |
lib/sentry/plug_capture.ex |
Plug exception capture |
lib/sentry/live_view_hook.ex |
Phoenix LiveView hook |
lib/mix/tasks/ |
Mix tasks (install, test event, source packaging) |
test/ |
Unit and integration tests |
test/support/ |
Test helpers and shared utilities |
test_integrations/ |
Multi-project integration tests (umbrella, phoenix_app, legacy_otel, tracing) |
config/ |
Application configuration |
pages/ |
Documentation pages |
- Elixir: ~> 1.13
- Install dependencies:
mix deps.get - Compile:
mix compile
| Command | Description |
|---|---|
mix deps.get |
Install dependencies |
mix compile |
Compile the project |
mix test |
Run the test suite |
mix format |
Format code |
mix format --check-formatted |
Check formatting (CI) |
mix dialyzer |
Run Dialyzer type checking |
mix test.integrations |
Run integration tests in test_integrations/ |
The SDK starts as an OTP application with a :one_for_one supervisor. Key children:
- Registry —
Sentry.Transport.SenderRegistryfor sender worker lookup - Sentry.Sources — Source code context for error reports
- Sentry.Dedupe — Event deduplication
- Sentry.ClientReport.Sender — Reports discarded events to Sentry
- HTTP Client — Pluggable (Finch or Hackney), started if it has
child_spec/0 - Sentry.OpenTelemetry.SpanStorage — ETS-backed span storage (when tracing is enabled)
- Sentry.TelemetryProcessor — Buffered event processing pipeline
- Sentry.Transport.RateLimiter — Sentry rate limit handling (disabled in test)
- Sentry.Transport.SenderPool — Pool of HTTP sender workers
After children start, integration handlers (Oban, Quantum, Telemetry) are attached and the logger handler is conditionally added.
The TelemetryProcessor is a supervisor managing the buffered event pipeline:
- 4 Ring Buffers — One per data category: error, check_in, transaction, log
- Scheduler — Weighted round-robin scheduling (error=5, check_in=4, transaction=3, log=2)
- QueueWorker — Bounded FIFO queue (default capacity 1000) between scheduler and HTTP transport
Events flow: Client → Buffer → Scheduler → QueueWorker → Transport
:sync— Events sent directly via Transport (used in tests):none— Events buffered through the TelemetryProcessor pipeline (production default)
Next major release: The TelemetryProcessor will become the sole mechanism for buffering, scheduling, and prioritizing all event types (errors, transactions, and logs). The
:syncsend mode and the legacySenderPoolpath will be removed, making the TelemetryProcessor pipeline the only and default way events are processed and delivered.
Configuration is validated at application start using NimbleOptions, then cached in :persistent_term. Runtime changes are possible via Sentry.put_config/2.
- Framework: ExUnit
- File naming:
*_test.exsfiles mirrorlib/structure undertest/ - Test helpers:
test/support/case.ex(Sentry.Case) andtest/support/test_helpers.ex - Fixtures:
test/fixtures/for umbrella app test data
- HTTP testing: Use
Bypassfor HTTP-level tests withsend_result: :sync. Usesetup_bypass/1to open a Bypass instance and configure DSN,setup_bypass_envelope_collector/1to forward envelopes to the test process, andcollect_envelopes/3+extract_events/1/extract_transactions/1/extract_log_items/1to retrieve and filter decoded envelope items. - Test isolation: Each test gets uniquely-named components (rate limiter, processor, span storage) via process dictionary and
:persistent_term - Config isolation: Use
put_test_config/1from test helpers for isolated config changes with automatic cleanup
Tests run with send_result: :sync (set in config/config.exs). This bypasses the TelemetryProcessor pipeline for direct, synchronous event sending. All tests that send events use Bypass to capture HTTP requests — there is no in-memory event collection.
The test_integrations/ directory contains standalone Mix projects:
umbrella/— Multi-app umbrella projectphoenix_app/— Full Phoenix application with HTTP integration testslegacy_otel/— Legacy OpenTelemetry backward compatibilitytracing/— End-to-end distributed tracing with Playwright
Run with: mix test.integrations
- Formatting:
mix format— imports formatting rules from:plug,:phoenix,:phoenix_live_view - Dialyzer:
mix dialyzer— known ignores in.dialyzer_ignore.exs - No Credo: This project does not use Credo
- Always ask clarifying questions or propose a plan before implementing large changes
- Write tests before or alongside implementation
- Do NOT commit or push code without explicit permission
- Follow existing patterns in the codebase
AI-assisted commits MUST include:
Co-Authored-By: <agent model name> <noreply@anthropic.com>
Example: Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Follow the Sentry commit message format: https://develop.sentry.dev/commit-messages/#commit-message-format