Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A Sentry client for Java
Java Python
Latest commit c8a5266 @tkaemming tkaemming Merge pull request #161 from getsentry/filename
Add filename to `StackTraceInterfaceBinding`.


Build Status Maven Central

Raven is the Java client for Sentry. Raven relies on the most popular logging libraries to capture and convert logs before sending details to a Sentry instance.

While it's strongly recommended to use one of the supported logging frameworks to capture and send messages to Sentry, a it is possible to do so manually with the main project raven.

Raven supports both HTTP(S) as transport protocols to the Sentry instance.

Support for Google App Engine is provided in raven-appengine

Sentry Protocol and Raven versions

Since Sentry 2.0, the major version of raven matches the version of the Sentry protocol.

Raven version Protocol version Sentry version
Raven 2.x(old) V2 >= 2.0
Raven 3.x(old) V3 >= 5.1
Raven 4.x(old) V4 >= 6.0
Raven 5.x V5 >= 6.4
Raven 6.x V6 >= 7.0

Each release of Sentry supports the last two version of the protocol (i.e. Sentry 6.4.2 supports both the protocol V5 and V4), for this reason, only the two last stable versions of Raven are actively maintained.

Snapshot versions

While the stable versions of raven are available on the central Maven Repository, newer (but less stable) versions (AKA snapshots) are available in Sonatype's snapshot repository.

To use it with maven, add the following repository:

    <name>Sonatype Nexus Snapshots</name>


Raven works on Android, and relies on the ServiceLoader system which uses the content of META-INF/services. This is used to declare the RavenFactory implementations (to allow more control over the automatically generated instances of Raven) in META-INF/services/net.kencochrane.raven.RavenFactory.

Unfortunately, when the APK is build, the content of META-INF/services of the dependencies is lost, this prevent Raven to work properly. Solutions exist for that problem:

  • Use maven-android-plugin which has already solved this problem
  • Create manually a META-INF/services/net.kencochrane.raven.RavenFactory for the project which will contain the canonical name of of implementation of RavenFactory (ie. net.kencochrane.raven.DefaultRavenFactory).
  • Register manually the RavenFactory when the application starts:

    RavenFactory.registerFactory(new DefaultRavenFactory());

Connection and protocol

It is possible to send events to Sentry over different protocols, depending on the security and performance requirements.


The most common way send events to Sentry is through HTTP, this can be done by using a DSN of this form:


If not provided, the port will default to 80.


It is possible to use an encrypted connection to Sentry using HTTPS:


If not provided, the port will default to 443.

HTTPS (naive)

If the certificate used over HTTPS is a wildcard certificate (which is not handled by every version of Java), and the certificate isn't added to the truststore, it is possible to add a protocol setting to tell the client to be naive and ignore the hostname verification:



It is possible to enable some options by adding data to the query string of the DSN:


Some options do not require a value, just being declared signifies that the option is enabled.

Async connection

In order to avoid performance issues due to a large amount of logs being generated or a slow connection to the Sentry server, an asynchronous connection is set up, using a low priority thread pool to submit events to Sentry.

To disable the async mode, add raven.async=false to the DSN:


Graceful Shutdown (advanced)

In order to shutdown the asynchronous connection gracefully, a ShutdownHook is created. This could lead to memory leaks in an environment where the life cycle of Raven doesn't match the life cycle of the JVM.

An example would be in a JEE environment where the application using Raven could be deployed and undeployed regularly.

To avoid this behaviour, it is possible to disable the graceful shutdown. This might lead to some log entries being lost if the log application doesn't shut down the Raven instance nicely.

The option to do so is raven.async.gracefulshutdown:


Queue size (advanced)

The default queue used to store the not yet processed events doesn't have a limit. Depending on the environment (if the memory is sparse) it is important to be able to control the size of that queue to avoid memory issues.

It is possible to set a maximum with the option raven.async.queuesize:


This means that if the connection to the Sentry server is down, only the 100 most recent events will be stored and processed as soon as the server is back up.

Threads count (advanced)

By default the thread pool used by the async connection contains one thread per processor available to the JVM (more threads wouldn't be useful).

It's possible to manually set the number of threads (for example if you want only one thread) with the option raven.async.threads:


Threads priority (advanced)

As in most cases sending logs to Sentry isn't as important as an application running smoothly, the threads have a minimal priority.

It is possible to customise this value to increase the priority of those threads with the option raven.async.priority:


Inapp classes

Sentry differentiate in_app stack frames (which are directly related to your application) and the "not in_app" ones. This difference is visible in the Sentry web interface where only the in_app frames are displayed by default.

Same frame as enclosing exception

Raven can use the in_app system to hide frames in the context of chained exceptions.

Usually when a StackTrace is printed, the result looks like this:

HighLevelException: MidLevelException: LowLevelException
        at Main.a(
        at Main.main(
Caused by: MidLevelException: LowLevelException
        at Main.c(
        at Main.b(
        at Main.a(
        ... 1 more
Caused by: LowLevelException
        at Main.e(
        at Main.d(
        at Main.c(
        ... 3 more

Some frames are replaced by the ... N more line as they are the same frames as in the enclosing exception.

To enable a similar behaviour from raven use the raven.stacktrace.hidecommon option.


Hide frames based on the class name

Raven can also mark some frames as in_app based on the name of the class.

This can be used to hide parts of the stacktrace that are irrelevant to the problem for example the stack frames in the java.util package will not help determining what the problem was and will just create a longer stacktrace.

Currently this is not configurable (see #49) and some packages are ignored by default:

  • com.sun.*
  • java.*
  • javax.*
  • org.omg.*
  • sun.*
  • junit.*
  • com.intellij.rt.*


By default the content sent to Sentry is compressed and encoded in base64 before being sent. This operation allows to send a smaller amount of data for each event. However compressing and encoding the data adds a CPU and memory overhead which might not be useful if the connection to Sentry is fast and reliable.

Depending on the limitations of the project (ie: a mobile application with a limited connection, Sentry hosted on an external network), it can be interesting to compress the data beforehand or not.

It's possible to manually enable/disable the compression with the option raven.compression


Timeout (advanced)

To avoid blocking the thread because of a connection taking too much time, a timeout can be set by the connection.

By default the connection will set up its own timeout, but it's possible to manually set one with raven.timeout (in milliseconds):

Something went wrong with that request. Please try again.