Quarkus Logging Sentry

This guide explains how to configure Quarkus to log to Sentry.

Description

Sentry is a really easy way to be notified of errors happening in your Quarkus application.

It is a self-hosted and cloud-based error monitoring that helps software teams discover, triage, and prioritize errors in real-time.

They offer a free starter price for cloud-based or you can self host it for free.

Sentry’s Java SDK is open source, but recently sentry.io changed the license for their backend to the non-open source BSL license. This might or might not be an issue for your project and product.

Configuration

To start with, you need to get a Sentry DSN either by creating a Sentry account or installing your own self-hosted Sentry.

In order to configure Sentry logging, add the logging-sentry extension to your project by running the following command in your project base directory:

./mvnw quarkus:add-extension -Dextensions="logging-sentry"

This will add the following to your pom.xml:

<dependency>
    <groupId>io.quarkiverse.loggingsentry</groupId>
    <artifactId>quarkus-logging-sentry</artifactId>
    <version>1.2.1</version>
</dependency>

“In Application” Stack Frames

Sentry differentiates stack frames that are directly related to your application (“in application”) from stack frames that come from other packages such as the standard library, frameworks, or other dependencies. The difference is visible in the Sentry web interface where only the “in application” frames are displayed by default.

You can configure which package prefixes your application uses with the in-app-packages option, which takes a comma separated list of packages:

quarkus.log.sentry.in-app-packages=com.mycompany,com.other.name

If you don’t want to use this feature but want to disable the warning, simply set it to *:

quarkus.log.sentry.in-app-packages=*

Example

All errors and warnings occurring in any of the packages will be sent to Sentry with DSN https://abcd@sentry.io/1234
quarkus.log.sentry=true
quarkus.log.sentry.dsn=https://abcd@sentry.io/1234
quarkus.log.sentry.in-app-packages=*
All errors occurring in the package org.example will be sent to Sentry with DSN https://abcd@sentry.io/1234
quarkus.log.sentry=true
quarkus.log.sentry.dsn=https://abcd@sentry.io/1234
quarkus.log.sentry.level=ERROR
quarkus.log.sentry.in-app-packages=org.example

Configuration Reference

This extension is configured through the standard application.properties file.

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

Type

Default

Determine whether to enable the Sentry logging extension.

boolean

false

Sentry DSN The DSN is the first and most important thing to configure because it tells the SDK where to send events. You can find your project’s DSN in the “Client Keys” section of your “Project Settings” in Sentry.

string

The sentry log level.

Level

WARN

The minimum event level. Every log statement that is greater than minimum event level is turned into Sentry event.

Level

WARN

The minimum breadcrumb level. Every log statement that is greater than minimum breadcrumb level is added to Sentry scope as a breadcrumb, which can be later attached to SentryEvent if one is triggered.

Level

INFO

Sentry differentiates stack frames that are directly related to your application (“in application”) from stack frames that come from other packages such as the standard library, frameworks, or other dependencies. The difference is visible in the Sentry web interface where only the “in application” frames are displayed by default. You can configure which package prefixes your application uses with this option. This option is highly recommended as it affects stacktrace grouping and display on Sentry. See documentation: https://quarkus.io/guides/logging-sentry#in-app-packages

list of string

Environment With Sentry you can easily filter issues, releases, and user feedback by environment. The environment filter on sentry affects all issue-related metrics like count of users affected, times series graphs, and event count. By setting the environment option, an environment tag will be added to each new issue sent to Sentry. There are a few restrictions: → the environment name cannot contain newlines or spaces, cannot be the string “None” or exceed 64 characters.

string

Release A release is a version of your code that is deployed to an environment. When you give Sentry information about your releases, you unlock a number of new features: - Determine the issues and regressions introduced in a new release - Predict which commit caused an issue and who is likely responsible - Resolve issues by including the issue number in your commit message - Receive email notifications when your code gets deployed

string

Server name Sets the server name that will be sent with each event.

string

Debug Enables Sentry debug mode.

boolean

false

This should be a float/double between 0.0 and 1.0 (inclusive) and represents the percentage chance that any given transaction will be sent to Sentry. So, barring outside influence, 0.0 is a 0% chance (none will be sent) and 1.0 is a 100% chance (all will be sent). This rate applies equally to all transactions.

double