Convert Figma logo to code with AI

getsentry logosentry-java

A Sentry SDK for Java, Android and other JVM languages.

1,139
432
1,139
283

Top Related Projects

BugSnag crash monitoring and reporting tool for Android apps

An asynchronous, callback-based Http client for Android built on top of Apache's HttpClient libraries.

Quick Overview

Sentry-java is the official Java SDK for Sentry, an error tracking and performance monitoring platform. It allows developers to integrate Sentry's error reporting and monitoring capabilities into Java applications, helping to identify, track, and resolve issues in real-time.

Pros

  • Easy integration with various Java frameworks and platforms
  • Comprehensive error tracking and performance monitoring
  • Automatic breadcrumb tracking for better context
  • Supports both synchronous and asynchronous event sending

Cons

  • Can add some overhead to application performance
  • Configuration might be complex for advanced use cases
  • Limited customization options for certain features
  • Requires careful management of sensitive data to avoid unintended exposure

Code Examples

  1. Basic Sentry initialization:
import io.sentry.Sentry;

Sentry.init(options -> {
  options.setDsn("https://examplePublicKey@o0.ingest.sentry.io/0");
  options.setTracesSampleRate(1.0);
});
  1. Capturing an exception:
try {
  throw new Exception("This is a test.");
} catch (Exception e) {
  Sentry.captureException(e);
}
  1. Adding custom context:
import io.sentry.Sentry;
import io.sentry.protocol.User;

User user = new User();
user.setEmail("jane.doe@example.com");
user.setId("123");
Sentry.setUser(user);

Sentry.setTag("page_locale", "de-at");
Sentry.setExtra("character_name", "Mighty Fighter");

Getting Started

  1. Add Sentry dependency to your project:

    For Maven:

    <dependency>
      <groupId>io.sentry</groupId>
      <artifactId>sentry</artifactId>
      <version>6.13.0</version>
    </dependency>
    

    For Gradle:

    implementation 'io.sentry:sentry:6.13.0'
    
  2. Initialize Sentry in your application:

    import io.sentry.Sentry;
    
    public class MyApplication {
      public static void main(String[] args) {
        Sentry.init(options -> {
          options.setDsn("https://examplePublicKey@o0.ingest.sentry.io/0");
          options.setTracesSampleRate(1.0);
        });
    
        // Your application code here
      }
    }
    
  3. Use Sentry to capture exceptions and events throughout your application.

Competitor Comparisons

BugSnag crash monitoring and reporting tool for Android apps

Pros of Bugsnag

  • More focused on Android-specific features and integrations
  • Simpler setup process for Android projects
  • Better documentation for Android-specific use cases

Cons of Bugsnag

  • Less flexible for non-Android Java projects
  • Fewer customization options for error handling
  • More limited support for custom data attachments

Code Comparison

Bugsnag initialization:

Bugsnag.start(this, "YOUR-API-KEY");

Sentry initialization:

import io.sentry.android.core.SentryAndroid;

SentryAndroid.init(this, options -> {
    options.setDsn("YOUR-DSN");
});

Both libraries offer simple initialization, but Sentry provides more configuration options out of the box.

Summary

Bugsnag is more tailored for Android development, offering a streamlined setup process and Android-specific features. However, Sentry-Java provides greater flexibility for various Java projects and more advanced customization options. Sentry's initialization allows for more detailed configuration, while Bugsnag's approach is simpler but less customizable. Choose Bugsnag for straightforward Android error tracking, or Sentry for more complex Java applications with diverse requirements.

An asynchronous, callback-based Http client for Android built on top of Apache's HttpClient libraries.

Pros of android-async-http

  • Lightweight and focused specifically on Android HTTP requests
  • Simple and intuitive API for making asynchronous HTTP calls
  • Built-in support for request cancellation and retry mechanisms

Cons of android-async-http

  • Limited to Android platform, not suitable for general Java applications
  • Less comprehensive error tracking and monitoring capabilities
  • Lacks advanced features like performance monitoring and release tracking

Code Comparison

android-async-http:

AsyncHttpClient client = new AsyncHttpClient();
client.get("https://api.example.com", new AsyncHttpResponseHandler() {
    @Override
    public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
        // Handle successful response
    }
});

sentry-java:

Sentry.init(options -> {
    options.setDsn("https://examplePublicKey@o0.ingest.sentry.io/0");
});
try {
    // Your code here
} catch (Exception e) {
    Sentry.captureException(e);
}

android-async-http focuses on simplifying HTTP requests in Android applications, providing an easy-to-use API for asynchronous network operations. sentry-java, on the other hand, is a more comprehensive error tracking and monitoring solution that works across various Java platforms, including Android. While android-async-http excels in its specific use case, sentry-java offers broader application monitoring capabilities, including performance tracking and error reporting, making it more suitable for large-scale applications requiring detailed insights into their operation and user experience.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Sentry

Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us Check out our open positions

Sentry SDK for Java and Android

GH Workflow codecov Discord Chat

PackagesMaven CentralMinimum Android API Version
sentry-androidMaven Central19
sentry-android-coreMaven Central19
sentry-android-ndkMaven Central19
sentry-android-okhttpMaven Central21
sentry-android-timberMaven Central19
sentry-android-fragmentMaven Central19
sentry-android-navigationMaven Central19
sentry-android-sqliteMaven Central19
sentry-android-replayMaven Central26
sentry-compose-androidMaven Central21
sentry-compose-desktopMaven Central
sentry-composeMaven Central
sentry-apache-http-client-5Maven Central
sentryMaven Central19
sentry-julMaven Central
sentry-jdbcMaven Central
sentry-apolloMaven Central19
sentry-apollo-3Maven Central19
sentry-kotlin-extensionsMaven Central19
sentry-servletMaven Central
sentry-servlet-jakartaMaven Central
sentry-spring-bootMaven Central
sentry-spring-boot-jakartaMaven Central
sentry-spring-boot-starterMaven Central
sentry-spring-boot-starter-jakartaMaven Central
sentry-springMaven Central
sentry-spring-jakartaMaven Central
sentry-logbackMaven Central
sentry-log4j2Maven Central
sentry-bomMaven Central
sentry-graphqlMaven Central
sentry-quartzMaven Central
sentry-openfeignMaven Central
sentry-opentelemetry-agentMaven Central
sentry-opentelemetry-agentcustomizationMaven Central
sentry-opentelemetry-coreMaven Central
sentry-okhttpMaven Central

Useful links and docs

Blog posts

Samples

Development

This repository includes sentry-native as a git submodule. To build against sentry-native checked-out elsewhere in your file system, create a symlink sentry-android-ndk/sentry-native-local that points to your sentry-native directory. For example, if you had sentry-native checked-out in a sibling directory to this repo:

ln -s ../../sentry-native sentry-android-ndk/sentry-native-local

which will be picked up by gradle and used instead of the git submodule. This directory is also included in .gitignore not to be shown as pending changes.

Sentry Self Hosted Compatibility

Since version 3.0.0 of this SDK, Sentry version >= v20.6.0 is required. This only applies to self-hosted Sentry, if you are using sentry.io no action is needed.

Since version 6.0.0 of this SDK, Sentry version >= v21.9.0 is required or you have to manually disable sending client reports via the sendClientReports option. This only applies to self-hosted Sentry, if you are using sentry.io no action is needed.

Since version 7.0.0 of this SDK, Sentry version >= 22.12.0 is required to properly ingest transactions with unfinished spans. This only applies to self-hosted Sentry, if you are using sentry.io no action is needed.

Resources

  • Java Documentation
  • Android Documentation
  • Discussions
  • Discord Chat
  • Stack Overflow
  • Code of Conduct
  • Twitter Follow