From fad136243f30227b67367a15190c3db4c240e286 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 | 8 +++++++- 1 file changed, 7 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..b9856f1dc98c 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,13 @@ 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