Make JvmThreadsMonitor injectable (#6369)

This commit is contained in:
Jihoon Son 2018-09-24 20:41:17 -07:00 committed by GitHub
parent 99428e20d2
commit d08c2c5eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -35,10 +35,15 @@ public class JvmThreadsMonitor extends FeedDefiningMonitor
private int lastLiveThreads = 0;
private long lastStartedThreads = 0;
public JvmThreadsMonitor(Map<String, String[]> dimensions)
{
this(dimensions, DEFAULT_METRICS_FEED);
}
public JvmThreadsMonitor(Map<String, String[]> dimensions, String feed)
{
super(feed);
Preconditions.checkNotNull(dimensions);
Preconditions.checkNotNull(dimensions, "dimensions");
this.dimensions = ImmutableMap.copyOf(dimensions);
}

View File

@ -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(