Handled / catched exceptions are getting into Azure Application Insights

Open
#3,838 12 comments 0 reactions 1 assignee View on GitHub

@heyams is already working on this.

Since Aug 15, 2024.

Assessment

This issue has not been assessed yet.

Description

Needs: Attention :wave:
Expected behavior

We have a handled exception in our application. When that exception is thrown and catched we should not see the occurrence of that exception in Application Insights.

Actual behavior

The thrown and catched exception is displayed in our Application Insights.

To Reproduce
  1. Create a new Spring Boot application with a scheduled task and use ShedLock to synchronize that task over multiple containers running in parallel with mongoDB setup (cosmos db)
// Run every 15 minutes (xx:00, xx:15, xx:30, xx:45)
@Scheduled(cron = "0 */15 * * * *")
@SchedulerLock(name = "uniqueString", lockAtMostFor = "14m", lockAtLeastFor = "14m")
public void myScheduledTask() {
    service.runTask();
}
  1. Setup the MongoLockProvider for ShedLock
@Bean
public LockProvider lockProvider(final MongoClient mongo) {
    return new MongoLockProvider(mongo.getDatabase(mongoDatabaseName));
}
  1. Setup Application Insights for the Spring Boot application
  2. Run the application with 2 containers in parallel (in our case in a container app)
  3. Observe the Application Insights Exceptions: Every time the task is scheduled ShedLock will try to lock the task in both containers. That means every time one of the containers will receive an duplicate key exception that is catched within the MongoLockProvider. These exceptions are shown in Application Insights.
System information

Please provide the following information:

  • SDK Version: Java SDK 21-temurin
  • OS type and version: eclipse-temurin:21-jre-alpine docker image
  • Application Server type and version (if applicable): Azure Container App
  • Using spring-boot? Yes with Spring-Boot-Starter-Parent v3.3.2
  • Additional relevant libraries (with version, if applicable): ShedLock v5.14.0 => net.javacrumbs.shedlock -> shedlock-spring & shedlock-provider-mongo
Dominant language
Java
Stars
327
Forks
222
Avg merge
22h 34m
Merged PRs (30d)
14

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/ApplicationInsights-Java

All issues in microsoft/ApplicationInsights-Java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.