diff --git a/java-util/src/main/java/org/apache/druid/java/util/metrics/JvmThreadsMonitor.java b/java-util/src/main/java/org/apache/druid/java/util/metrics/JvmThreadsMonitor.java index acb7783d066..eabb3a434c1 100644 --- a/java-util/src/main/java/org/apache/druid/java/util/metrics/JvmThreadsMonitor.java +++ b/java-util/src/main/java/org/apache/druid/java/util/metrics/JvmThreadsMonitor.java @@ -35,10 +35,15 @@ public class JvmThreadsMonitor extends FeedDefiningMonitor private int lastLiveThreads = 0; private long lastStartedThreads = 0; + public JvmThreadsMonitor(Map dimensions) + { + this(dimensions, DEFAULT_METRICS_FEED); + } + public JvmThreadsMonitor(Map dimensions, String feed) { super(feed); - Preconditions.checkNotNull(dimensions); + Preconditions.checkNotNull(dimensions, "dimensions"); this.dimensions = ImmutableMap.copyOf(dimensions); } diff --git a/server/src/main/java/org/apache/druid/server/metrics/MetricsModule.java b/server/src/main/java/org/apache/druid/server/metrics/MetricsModule.java index 11d8162f43b..7e3a25a535c 100644 --- a/server/src/main/java/org/apache/druid/server/metrics/MetricsModule.java +++ b/server/src/main/java/org/apache/druid/server/metrics/MetricsModule.java @@ -31,6 +31,7 @@ import com.google.inject.name.Names; import org.apache.druid.java.util.emitter.service.ServiceEmitter; import org.apache.druid.java.util.metrics.JvmCpuMonitor; import org.apache.druid.java.util.metrics.JvmMonitor; +import org.apache.druid.java.util.metrics.JvmThreadsMonitor; import org.apache.druid.java.util.metrics.Monitor; import org.apache.druid.java.util.metrics.MonitorScheduler; import org.apache.druid.java.util.metrics.SysMonitor; @@ -129,6 +130,18 @@ public class MetricsModule implements Module )); } + @Provides + @ManageLifecycle + public JvmThreadsMonitor getJvmThreadsMonitor(DataSourceTaskIdHolder dataSourceTaskIdHolder) + { + return new JvmThreadsMonitor( + MonitorsConfig.mapOfDatasourceAndTaskID( + dataSourceTaskIdHolder.getDataSource(), + dataSourceTaskIdHolder.getTaskId() + ) + ); + } + @Provides @ManageLifecycle public SysMonitor getSysMonitor(