agentleFS
SentryKnown publishergetsentry/sentry-java/AGENTS.md

sentry-java

AGENTS.md1.4k starsChanged 7 months agoMITView on GitHub

This file covers the whole repository. Before working on a specific area, read the matching rule file in .cursor/rules/: Rules can be combined — a tracing scope issue may need both scopes and opentelemetry. There is no rule for Android profiling yet; read the sentry-android-core profiling code directly and fetch related rules such as options, offline, or api as needed. This is the Sentry Java/Android SDK - a comprehensive error monitoring and performance tracking SDK for Java and Android applications.…

Trending

Quiet this year.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the getsentry/sentry-java repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about getsentry/sentry-java

The biggest 5 of 18 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 18

Talked about on GitHub (18 times).

On GitHub · 18

13 more on GitHub

The file

We split this AGENTS.md into the rules it gives an agent

9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    First think through the problem: Read the codebase for relevant files and propose a plan

    line 72
  2. Distinctive:

    Check in before beginning: Verify the plan before starting implementation

    line 73
  3. Distinctive:

    Write comprehensive unit tests for new features

    line 159
  4. Distinctive:

    Follow existing code style and language

    line 166
  5. Distinctive:

    When adapting code from third-party libraries:

    line 172
  6. Very specific:

    Add a license header at the top of the adapted file (before the package statement):

    line 173
  7. Very specific:

    Add a full attribution entry to THIRD_PARTY_NOTICES.md following the existing format (Source, License, Copyright, Scope, full license text)

    line 180
  8. Very specific:

    Run the check-code-attribution skill locally or wait for it to be auto-run against your PR to check for required fields and verify new …

    line 182
  9. Very specific:

    Use gh pr view to get PR details from the current branch.

    line 186

≈ “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

AGENTS.md

This file provides guidance to AI coding agents when working with code in this repository.

Domain-Specific Rules

This file covers the whole repository. Before working on a specific area, read the matching rule file in .cursor/rules/:

RuleRead it when working on
apiPublic API surface, binary compatibility, .api files, apiDump, IScope/IScopes/Sentry static API, protocol classes
optionsSentryOptions, namespaced options, ExternalOptions, sentry.properties, ManifestMetadataReader, Spring Boot properties
scopesScope management, forking, lifecycle, ScopeType, thread-local storage, scope bleeding, Hub → Scopes migration
deduplicationDuplicate event detection, DuplicateEventDetectionEventProcessor, enableDeduplication
offlineCaching, envelope storage, network failure handling, retries, AsyncHttpTransport, EnvelopeCache, rate limiting
feature_flagsaddFeatureFlag, FeatureFlagBuffer, maxFeatureFlags, LaunchDarkly and OpenFeature integrations
metricsSentry.metrics(), IMetricsApi, count/distribution/gauge, MetricsBatchProcessor
queuesQueue tracing, queue.publish/queue.process, enableQueueTracing, Kafka instrumentation, messaging span data
continuous_profiling_jvmsentry-async-profiler, IContinuousProfiler, ProfileChunk, JFR files, ProfileLifecycle
opentelemetrysentry-opentelemetry-*, agent vs agentless, span processing, sampling, context propagation
new_moduleAdding a new integration or sample module
e2e_testsSystem tests, sample applications, system-test-runner.py, mock Sentry server

Rules can be combined — a tracing scope issue may need both scopes and opentelemetry. There is no rule for Android profiling yet; read the sentry-android-core profiling code directly and fetch related rules such as options, offline, or api as needed.

Project Overview

This is the Sentry Java/Android SDK - a comprehensive error monitoring and performance tracking SDK for Java and Android applications. The repository contains multiple modules for different integrations and platforms.

Build System

The project uses Gradle with Kotlin DSL. Key build files:

  • build.gradle.kts - Root build configuration
  • settings.gradle.kts - Multi-module project structure
  • buildSrc/ and build-logic/ - Custom build logic and plugins
  • Makefile - High-level build commands

Essential Commands

# Format code and regenerate .api files (REQUIRED before committing)
./gradlew spotlessApply apiDump

# Run all tests and linter
./gradlew check

# Generate documentation
./gradlew aggregateJavadocs

# Dependency updates check
./gradlew dependencyUpdates -Drevision=release

To run tests, use the test skill rather than composing the Gradle invocation by hand — it resolves the per-module test task and the unit-test vs system-test split for you.

Android-Specific Commands

# Assemble Android test APKs
./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleRelease :sentry-android-integration-tests:sentry-uitest-android:assembleAndroidTest

# Run critical UI tests
./scripts/test-ui-critical.sh

Development Workflow Rules

Planning and Implementation Process

  1. First think through the problem: Read the codebase for relevant files and propose a plan
  2. Check in before beginning: Verify the plan before starting implementation
  3. Use todo tracking: Work through todo items, marking them as complete as you go
  4. High-level communication: Give high-level explanations of changes made, not step-by-step descriptions
  5. Simplicity first: Make every task and code change as simple as possible. Avoid massive or complex changes. Impact as little code as possible.
  6. Format and regenerate: Once done, format code and regenerate .api files: ./gradlew spotlessApply apiDump
  7. Propose commit: As final step, git stage relevant files and propose (but not execute) a single git commit command. This applies to implementation work; when the task is to open a PR, the create-java-pr skill takes over from here and does commit, push, and open it.

Repository Skills

This repo ships task-specific skills, declared in agents.toml with sources under .agents/skills. Your harness already lists them with their descriptions — prefer them over performing the steps manually.

Module Architecture

The repository is organized into multiple modules:

Core Modules

  • sentry - Core Java SDK implementation
  • sentry-android-core - Core Android SDK implementation
  • sentry-android - High-level Android SDK
  • sentry-android-ndk - Native (NDK) crash handling

Integration Modules

  • Spring Framework: sentry-spring*, sentry-spring-boot*
  • Logging: sentry-logback, sentry-log4j2, sentry-jul, sentry-android-timber
  • Web: sentry-servlet*, sentry-okhttp, sentry-openfeign, sentry-apache-http-client-5
  • GraphQL: sentry-graphql*, sentry-apollo*
  • Android UI: sentry-android-fragment, sentry-android-navigation, sentry-android-navigation3, sentry-compose
  • Session Replay: sentry-android-replay
  • Database: sentry-jdbc, sentry-android-sqlite, sentry-jcache
  • Reactive: sentry-reactor, sentry-ktor-client
  • Feature Flags: sentry-launchdarkly-android, sentry-launchdarkly-server, sentry-openfeature
  • Queues: sentry-kafka
  • Profiling: sentry-async-profiler (JVM continuous profiling)
  • Monitoring: sentry-opentelemetry*, sentry-quartz
  • Other: sentry-spotlight, sentry-kotlin-extensions, sentry-android-distribution

Utility Modules

  • sentry-test-support - Shared test utilities
  • sentry-system-test-support - System testing infrastructure
  • sentry-samples - Example applications
  • sentry-bom - Bill of Materials for dependency management

Key Architectural Patterns

  • Multi-platform: Supports JVM, Android, and Kotlin Multiplatform (Compose modules)
  • Modular Design: Each integration is a separate module with minimal dependencies
  • Options Pattern: Features are opt-in via SentryOptions and similar configuration classes
  • Transport Layer: Pluggable transport implementations for different environments
  • Scope Management: Thread-safe scope/context management for error tracking

Development Guidelines

Code Style

  • Languages: Java 8+ and Kotlin
  • Formatting: Enforced via Spotless
  • API Compatibility: Binary compatibility is enforced. .api files are generated, never hand-edited

Exception Handling

Never introduce a new catch (Throwable). Catch the narrowest type the guarded code can actually throw. The repository still contains many pre-existing broad catches; they are legacy, not a precedent to follow.

A broad catch swallows OutOfMemoryError, StackOverflowError, ThreadDeath and LinkageError — conditions the JVM/ART cannot recover from and that leave the process in an undefined state — and it hides real bugs in our own code behind a log line.

"The SDK must never crash the host application" is not a reason to catch Throwable. That goal is served by io.sentry.util.ExceptionUtils.rethrowIfFatal, which lets the non-recoverable throwables through while leaving everything else for the caller to log or ignore:

try {
  doSomethingRisky();
} catch (Throwable t) {
  ExceptionUtils.rethrowIfFatal(t);
  options.getLogger().log(SentryLevel.ERROR, "Failed to do something risky", t);
}

Apply that pattern only where a broad catch is genuinely unavoidable — an entry point that runs arbitrary user code or third-party callbacks. Everywhere else, name the exception types. Say in the PR description why the broad catch is necessary.

Testing Requirements

  • Write comprehensive unit tests for new features
  • Android modules require both unit tests and instrumented tests where applicable
  • System tests validate end-to-end functionality with sample applications
  • Assertions: For new unit tests, prefer Google Truth (com.google.common.truth.Truth.assertThat) over kotlin.test/JUnit assertions for its readable, fluent API. Keep using kotlin.test for test structure (@Test, assertFailsWith). See sentry/src/test/java/io/sentry/DsnTest.kt for the style. Don't rewrite existing kotlin.test assertions solely to switch libraries.
  • Truth is wired into the sentry module. When adding Truth-based tests to another module, add testImplementation(libs.google.truth) to that module's build.gradle.kts.

Contributing Guidelines

  1. Follow existing code style and language
  2. Write comprehensive tests
  3. New features must be opt-in by default - extend SentryOptions or similar Option classes with getters/setters
  4. Consider backwards compatibility

Third-Party Code Attribution

When adapting code from third-party libraries:

  1. Add a license header at the top of the adapted file (before the package statement):
    // Adapted from <Library Name>.
    // Copyright <year> <copyright holder>.
    // Licensed under the <License Name>.
    // <source URL>
  2. Add a full attribution entry to THIRD_PARTY_NOTICES.md following the existing format (Source, License, Copyright, Scope, full license text)
  3. Run the check-code-attribution skill locally or wait for it to be auto-run against your PR to check for required fields and verify new licenses against Sentry's Open Source Legal Policy.

Getting PR Information

Use gh pr view to get PR details from the current branch. This is needed when adding changelog entries, which require the PR number.

# Get PR number for current branch
gh pr view --json number -q '.number'

# Get PR number for a specific branch
gh pr view <branch-name> --json number -q '.number'

# Get PR URL
gh pr view --json url -q '.url'

Changelog

User-facing changes get an entry under the ## Unreleased section of CHANGELOG.md. The create-java-pr skill is the source of truth for the full changelog and PR workflow, including subsection selection and the rebase caveat when a release renames ## Unreleased.

Useful Resources

This SDK is production-ready and used by thousands of applications. Changes should be thoroughly tested and maintain backwards compatibility.

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.