From a338dad29c20385d73beaa630e1a36ee4b3ec609 Mon Sep 17 00:00:00 2001 From: yzc Date: Sat, 11 May 2024 09:51:39 +0800 Subject: [PATCH] use daemon thread for schedule in jmx-metrics BeanFinder --- .../instrumentation/jmx/engine/BeanFinder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanFinder.java b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanFinder.java index f3da0cef7efa..895d6587a18b 100644 --- a/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanFinder.java +++ b/instrumentation/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanFinder.java @@ -25,7 +25,12 @@ class BeanFinder { private final MetricRegistrar registrar; private MetricConfiguration conf; - private final ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(); + private final ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor( + runnable -> { + Thread result = new Thread(runnable, "jmx_bean_finder"); + result.setDaemon(true); + return result; + }); private final long discoveryDelay; private final long maxDelay; private long delay = 1000; // number of milliseconds until first attempt to discover MBeans