Skip to content

Commit 1a932c6

Browse files
authored
IO and Security exceptions do not deserve a trace dump (#1353)
Signed-off-by: Robert Szulist <robert@szuro.net>
1 parent 3b43e59 commit 1a932c6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

collector/src/main/java/io/prometheus/jmx/JmxCollector.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,19 +1019,26 @@ public MetricSnapshots collect() {
10191019
jmxMBeanPropertyCache);
10201020

10211021
long start = System.nanoTime();
1022-
double error = 0;
1022+
double error = 1;
1023+
String errorMsg = "";
10231024

10241025
if ((config.startDelaySeconds > 0)
10251026
&& ((start - createTimeNanoSecs) / 1000000000L < config.startDelaySeconds)) {
10261027
throw new IllegalStateException("JMXCollector waiting for startDelaySeconds");
10271028
}
10281029
try {
10291030
scraper.doScrape();
1031+
error = 0;
1032+
} catch (java.io.IOException | java.lang.SecurityException e) {
1033+
errorMsg = e.getMessage();
10301034
} catch (Exception e) {
1031-
error = 1;
10321035
StringWriter sw = new StringWriter();
10331036
e.printStackTrace(new PrintWriter(sw));
1034-
LOGGER.error("JMX scrape failed: %s", sw);
1037+
errorMsg = sw.toString();
1038+
}
1039+
1040+
if (error == 1) {
1041+
LOGGER.error("JMX scrape failed: %s", errorMsg);
10351042
}
10361043

10371044
if (config.rulesCache != null) {

0 commit comments

Comments
 (0)