sentry-elixir
AGENTS.md693 starsChanged 10 days agoMITView on GitHub
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. The SDK starts as an OTP application with a :one_for_one supervisor. Key children: 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…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 33,398 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 65
After children start, integration handlers (Oban, Quantum, Telemetry) are attached and the logger handler is conditionally added.
- Very specific: line 99
HTTP testing: Use Bypass for HTTP-level tests with send_result: :sync.
- Very specific: line 101
Config isolation: Use put_test_config/1 from test helpers for isolated config changes with automatic cleanup
- Distinctive: line 127
Always ask clarifying questions or propose a plan before implementing large changes
- Distinctive: line 128
Write tests before or alongside implementation
- Distinctive: line 129
Do NOT commit or push code without explicit permission
- Distinctive: line 130
Follow existing patterns in the codebase
- Distinctive: line 144
Follow the Sentry commit message format: https://develop.sentry.dev/commit-messages/#commit-message-format
≈ “Common” is an estimate: at least 1 in 5 of the 43,423 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Sentry Elixir SDK - Agent Guide
Overview
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.
Project Structure
| 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, legacy_telemetry_poller, tracing) |
config/ | Application configuration |
pages/ | Documentation pages |
Environment & Setup
- Elixir: ~> 1.13
- Install dependencies:
mix deps.get - Compile:
mix compile
Key Commands
| 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/ |
Architecture
OTP Application Tree (Sentry.Application)
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 (not started in test mode;
Sentry.Teststarts one per test) - 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.
TelemetryProcessor Pipeline
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
Send Modes
: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
Configuration is validated at application start using NimbleOptions, then cached in :persistent_term. Runtime changes are possible via Sentry.put_config/2.
Testing Conventions
Framework & Organization
- 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
Key Patterns
- 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
Test Configuration
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.
Integration Tests
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 compatibilitylegacy_telemetry_poller/— telemetry_poller 0.5 and telemetry 0.4 compatibilitytracing/— End-to-end distributed tracing with Playwright
Run with: mix test.integrations
Code Quality
- 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
Key Principles
- 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
Commit Attribution
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>
Commit Message Guidelines
Follow the Sentry commit message format: https://develop.sentry.dev/commit-messages/#commit-message-format
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

