agentleFS
SentryKnown publishergetsentry/sentry-elixir/AGENTS.md

sentry-elixir

AGENTS.md694 starsChanged 3 months 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 checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 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.

  • In this repositoryOne other file it gives its agents.

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
  1. Distinctive:

    After children start, integration handlers (Oban, Quantum, Telemetry) are attached and the logger handler is conditionally added.

    line 65
  2. Very specific:

    HTTP testing: Use Bypass for HTTP-level tests with send_result: :sync.

    line 99
  3. Very specific:

    Config isolation: Use put_test_config/1 from test helpers for isolated config changes with automatic cleanup

    line 101
  4. Distinctive:

    Always ask clarifying questions or propose a plan before implementing large changes

    line 126
  5. Distinctive:

    Write tests before or alongside implementation

    line 127
  6. Distinctive:

    Do NOT commit or push code without explicit permission

    line 128
  7. Distinctive:

    Follow existing patterns in the codebase

    line 129
  8. Distinctive:

    Follow the Sentry commit message format: https://develop.sentry.dev/commit-messages/#commit-message-format

    line 143

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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

PathDescription
lib/sentry.exMain public API (capture_exception, capture_message)
lib/sentry/application.exOTP Application supervisor
lib/sentry/client.exEvent creation, sampling, and callbacks
lib/sentry/config.exConfiguration validation and persistence
lib/sentry/transport.exHTTP transport abstraction
lib/sentry/transport/Sender pool, rate limiter
lib/sentry/telemetry/Ring buffers, scheduler, queue worker
lib/sentry/telemetry_processor.exSupervisor for buffered event processing
lib/sentry/opentelemetry/OpenTelemetry span processor, sampler, propagator
lib/sentry/integrations/Oban, Quantum, Telemetry integrations
lib/sentry/logger_handler.exErlang logger handler
lib/sentry/plug_capture.exPlug exception capture
lib/sentry/live_view_hook.exPhoenix 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

Environment & Setup

  • Elixir: ~> 1.13
  • Install dependencies: mix deps.get
  • Compile: mix compile

Key Commands

CommandDescription
mix deps.getInstall dependencies
mix compileCompile the project
mix testRun the test suite
mix formatFormat code
mix format --check-formattedCheck formatting (CI)
mix dialyzerRun Dialyzer type checking
mix test.integrationsRun 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:

  1. Registry — Sentry.Transport.SenderRegistry for sender worker lookup
  2. Sentry.Sources — Source code context for error reports
  3. Sentry.Dedupe — Event deduplication
  4. Sentry.ClientReport.Sender — Reports discarded events to Sentry (not started in test mode; Sentry.Test starts one per test)
  5. HTTP Client — Pluggable (Finch or Hackney), started if it has child_spec/0
  6. Sentry.OpenTelemetry.SpanStorage — ETS-backed span storage (when tracing is enabled)
  7. Sentry.TelemetryProcessor — Buffered event processing pipeline
  8. Sentry.Transport.RateLimiter — Sentry rate limit handling (disabled in test)
  9. 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 :sync send mode and the legacy SenderPool path 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.exs files mirror lib/ structure under test/
  • Test helpers: test/support/case.ex (Sentry.Case) and test/support/test_helpers.ex
  • Fixtures: test/fixtures/ for umbrella app test data

Key Patterns

  • HTTP testing: Use Bypass for HTTP-level tests with send_result: :sync. Use setup_bypass/1 to open a Bypass instance and configure DSN, setup_bypass_envelope_collector/1 to forward envelopes to the test process, and collect_envelopes/3 + extract_events/1 / extract_transactions/1 / extract_log_items/1 to 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/1 from 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 project
  • phoenix_app/ — Full Phoenix application with HTTP integration tests
  • legacy_otel/ — Legacy OpenTelemetry backward compatibility
  • tracing/ — 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.