Skip to content

Commit

Permalink
Merge pull request #36 from digipost/asyncupdater-catchall
Browse files Browse the repository at this point in the history
Catch all thrown stuff in AsyncUpdater
  • Loading branch information
runeflobakk authored Mar 4, 2025
2 parents c62ce4a + 23dfc7c commit 4fc4737
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
1 change: 0 additions & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ This software includes third party software subject to the following licenses:
Prometheus Metrics Exposition Formats under The Apache Software License, Version 2.0
Prometheus Metrics Model under The Apache Software License, Version 2.0
Prometheus Metrics Tracer Common under The Apache Software License, Version 2.0
Shaded Protobuf under The Apache Software License, Version 2.0

40 changes: 23 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,36 @@

<properties>
<maven.compiler.release>11</maven.compiler.release>
<logback.version>1.4.14</logback.version>
<logback.version>1.5.17</logback.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-bom</artifactId>
<version>1.13.1</version>
<version>1.14.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-bom</artifactId>
<version>2.0.17</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.11.0-M2</version>
<version>5.12.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-bom</artifactId>
<version>5.12.0</version>
<version>5.16.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -103,7 +110,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.13</version>
<optional>true</optional>
</dependency>

Expand All @@ -125,7 +131,7 @@
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<version>3.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -148,7 +154,7 @@
<dependency>
<groupId>no.digipost</groupId>
<artifactId>digg</artifactId>
<version>0.34</version>
<version>0.36</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -158,15 +164,15 @@
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.3.2</version>
<version>3.4.1</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<version>3.14.0</version>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
Expand All @@ -190,31 +196,31 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<version>3.5.2</version>
<configuration>
<argLine>-Djava.util.logging.config.file=/logging.properties</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.1</version>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.1</version>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
<version>3.1.4</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
<version>3.1.4</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.16.2</version>
<version>2.18.0</version>
</plugin>
<plugin>
<groupId>org.jasig.maven</groupId>
Expand All @@ -224,12 +230,12 @@
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>4.5</version>
<version>4.6</version>
</plugin>
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
<version>0.21.2</version>
<version>0.23.1</version>
<configuration>
<parameter>
<includes>
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/no/digipost/monitoring/async/AsyncUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import java.util.logging.Level;
import java.util.logging.Logger;

import static java.util.logging.Level.WARNING;

class AsyncUpdater implements Runnable {

private static final Logger LOG = Logger.getLogger(AsyncUpdater.class.getName());
Expand All @@ -46,8 +47,10 @@ public void run() {
updateNewValues.run();
lastUpdate = clock.instant();
lastUpdateSuccessful = true;
} catch (Exception e) {
LOG.log(Level.WARNING, "Unexpected exception in updater '" + updaterName + "' while updating metrics.", e);
} catch (Throwable e) {
LOG.log(WARNING,
"Unexpected exception in updater '" + updaterName + "' while updating metrics: " +
e.getClass().getSimpleName() + " " + e.getMessage(), e);
lastUpdateSuccessful = false;
}
}
Expand Down

0 comments on commit 4fc4737

Please sign in to comment.