Sentry SDK for Java and Android

repository·main·Indexed 23 days ago

https://github.com/getsentry/sentry-java

A comprehensive error reporting and performance monitoring toolset for JVM and Android applications. It provides error tracking, performance monitoring, and session replay, with specialized packages for Spring Boot, Android, Ktor, OpenTelemetry, and other frameworks. The SDK includes a core library, a Bill of Materials (sentry-bom), and various integrations for logging, HTTP clients, and reactive frameworks.

Tokens
16.1K
Snippets
47
Records
108
Agent score
79%

What's inside sentry-java

  1. Overview of sentry-compose modules

    main

    The sentry-compose module provides Compose-based integration for Sentry. The module is structured into three main outputs:

    1. sentry-compose: The core module.
    2. sentry-compose-android: An Android-specific implementation that depends on sentry-compose.
    3. sentry-compose-desktop: A Desktop-specific implementation that depends on sentry-compose.
  2. Overview of Sentry SDK for Java and Android

    main
    The Sentry SDK for Java and Android provides error tracking, performance monitoring, and session replay capabilities for applications running on the JVM and Android platforms. The SDK is distributed through various specialized packages to support different frameworks, libraries, and environments (e.g., Spring Boot, Android, Ktor, OpenTelemetry, and more).
  3. Overview of sentry-kafka

    main

    The sentry-kafka module provides Kafka-native queue instrumentation for Java applications that use the kafka-clients library directly. It allows you to capture errors and performance data from Kafka operations within your application.

    Note for Spring users: If you are using Spring Kafka, do not use this module. Instead, use the Sentry Spring (Boot) SDKs, which offer higher-fidelity consumer instrumentation through specialized Spring Kafka hooks.

  4. Sentry OpenTelemetry Modules Overview

    main

    The sentry-opentelemetry project is divided into several modules depending on your integration method:

    • sentry-opentelemetry-agent: Provides the JAR for auto-instrumentation.
    • sentry-opentelemetry-agentcustomization: Contains customizations for the OpenTelemetry Java Agent (e.g., registering SentrySpanProcessor and SentryPropagator).
    • sentry-opentelemetry-bootstrap: Shared classes (storage, utils, factory, tokens) required by both the agent and agentless modes.
    • sentry-opentelemetry-core: Contains SentrySpanProcessor and SentryPropagator for manual instrumentation.
    • sentry-opentelemetry-agentless: A bundle of all modules needed for non-agent OpenTelemetry integration.
    • sentry-opentelemetry-agentless-spring: A bundle optimized for Spring Boot applications using the agentless approach.
  5. Use Sentry with JCache (JSR-107)

    main

    The sentry-jcache module provides an integration for JCache (JSR-107) to enable Sentry monitoring for caching operations.

    Because JCache is a standard API, you must include a JCache provider implementation in your runtime environment. Common compatible providers include:

    • Caffeine (using com.github.ben-manes.caffeine:jcache)
    • Ehcache 3 (using org.ehcache:ehcache)
    • Hazelcast
    • Apache Ignite
    • Infinispan
  6. Use the Sentry Ktor Client plugin

    main

    The sentry-ktor-client module provides a Ktor plugin designed for automatic instrumentation of the Ktor HTTP Client. When installed, it enables:

    • Error capturing: Automatically captures errors occurring during HTTP requests.
    • Breadcrumbs: Automatically records request and response details as breadcrumbs.
    • Distributed tracing: Supports distributed tracing by propagating trace headers across HTTP calls.

    For specific implementation details and setup instructions, refer to the official Sentry documentation for your platform:

  7. Explore Android performance-impact and integration test samples

    main

    The sentry-android-integration-tests directory contains sample applications and test suites used to measure the performance impact of Sentry on Android and verify integration.

    • Plain Sample App: A standard Android Studio 'Basic Activity' project without Sentry integration. Located at ./test-app-plain.
    • Sentry-Enabled Sample App: The same application but with Sentry integrated. Located at ./test-app-sentry.
    • Metrics Specification: The YAML file defining app metrics tests can be found at ./metrics-test.yml.
    • UI and Benchmark Tests: Espresso-based benchmarks and UI tests are available in ./sentry-uitest-android-benchmark and ./sentry-uitest-android respectively. These are designed to run within SauceLabs (refer to /.sauce/*.yml for configuration).
  8. Use sentry-opentelemetry-otlp-spring for Spring Boot applications

    main

    The sentry-opentelemetry-otlp-spring module provides a simplified setup for Spring Boot applications by combining sentry-opentelemetry-otlp with the OpenTelemetry Spring Boot Starter.

    This module is designed for architectures where:

    1. OpenTelemetry manages tracing (exporting spans via OTLP to Sentry).
    2. Sentry manages errors, logs, metrics, and other Sentry products.

    For detailed installation and usage instructions, refer to the official Sentry Docs for Java.

  9. What is the sentry-opentelemetry-bom?

    main

    The sentry-opentelemetry-bom is a Bill of Materials (BOM) designed to align Sentry OpenTelemetry modules with the specific OpenTelemetry artifact versions tested by Sentry.

    When to use it: Use this BOM only when you want Sentry to manage OpenTelemetry dependency versions for Sentry's OpenTelemetry integrations (such as sentry-opentelemetry-agentless, sentry-opentelemetry-agentless-spring, sentry-opentelemetry-otlp, and sentry-opentelemetry-otlp-spring).

    Important considerations:

    • It manages stable and -alpha OpenTelemetry artifacts, including incubator artifacts.
    • It makes Sentry's tested versions authoritative. If your application already uses newer OpenTelemetry versions, verify dependency resolution before importing.
    • It does not change the OpenTelemetry dependencies shaded into the sentry-opentelemetry-agent Java agent JAR.