Error monitoring in Spring Boot application using Sentry

Manoj Ahirwar
2 min readMar 7, 2022

--

Photo by Randy Laybourne on Unsplash

When building products, the hard thing is finding the bugs in your application after moving to production. When your users are using the application and found that server issue, How do you get to know about that problem so you can fix the problem before users start to complain about the application?

There are many services that offer this solution and one of them is Sentry. Sentry is a platform that can be integrated with your apps very easily and will give you all the insights about the exceptions that your application is generating.

You can start using sentry by simply signing up to the platform https://sentry.io/ and creating a new application. after creating your application, Sentry will give you the app id which is DSN (Data source name).

In order to integrate sentry in your spring boot, all you need to do is add its dependency in your pom.xml and add some properties in your application.yml file

Add the following dependency in your pom.xml

<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring-boot-starter</artifactId>
<version>5.6.2</version>
</dependency>

then add your sentry DSN in your application property file

sentry.dsn=https://examplePublicKey@o0.ingest.sentry.io/0

To test the integration. just throw a new exception from your application.

throw new Exception("This is a test.");

and you should be able to see the exception captured in the sentry dashboard.

Another thing I like about sentry is, How easy it give all the insights on the dashboard and integration to another platform like Slack, Squadcast so that your team can be notified about the issue right away.

I have been using sentry in all of my personal projects as it is free to use for personal use.

Hope you like this article.

Cheers!!

--

--

No responses yet