prometheus to micrometer

1.4.1
chen.ma 2 years ago
parent bdec8f5052
commit 17b6970c11

@ -51,7 +51,7 @@ management:
spring:
dynamic:
thread-pool:
collect-type: prometheus
collect-type: micrometer
```
Prometheus 配置任务,配置成功后需重启。

@ -46,7 +46,7 @@ spring:
enable: true
# 是否打印 banner
banner: true
# 是否开启线程池数据采集,对接 Prometheus、ES、Log 等
# 是否开启线程池数据采集,对接 Micrometer、ES、Log 等
collect: true
# 检查线程池状态,是否达到报警条件,单位毫秒
check-state-interval: 3000

@ -22,7 +22,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDynamicThreadPool
@SpringBootApplication(scanBasePackages = "cn.hippo4j.example.config")
@SpringBootApplication(scanBasePackages = "cn.hippo4j.example.core")
public class ConfigApolloExampleApplication {
public static void main(String[] args) {

@ -22,7 +22,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDynamicThreadPool
@SpringBootApplication(scanBasePackages = "cn.hippo4j.example.config")
@SpringBootApplication(scanBasePackages = "cn.hippo4j.example.core")
public class ConfigNacosExampleApplication {
public static void main(String[] args) {

@ -18,7 +18,7 @@ spring.cloud.nacos.config.extension-configs[0].refresh=true
spring.dynamic.thread-pool.enable=true
spring.dynamic.thread-pool.banner=true
spring.dynamic.thread-pool.collect=true
spring.dynamic.thread-pool.collect-type=prometheus
spring.dynamic.thread-pool.collect-type=micrometer
spring.dynamic.thread-pool.check-state-interval=5
spring.dynamic.thread-pool.notify-platforms[0].platform=WECHAT

@ -22,7 +22,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDynamicThreadPool
@SpringBootApplication(scanBasePackages = "cn.hippo4j.example.config")
@SpringBootApplication(scanBasePackages = "cn.hippo4j.example.core")
public class ConfigZookeeperExampleApplication {
public static void main(String[] args) {

@ -38,7 +38,7 @@
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-spring-boot-starter-monitor-prometheus</artifactId>
<artifactId>hippo4j-spring-boot-starter-monitor-micrometer</artifactId>
<version>${revision}</version>
</dependency>

@ -18,5 +18,5 @@ spring.dynamic.thread-pool.item-id=dynamic-threadpool-example
spring.dynamic.thread-pool.username=admin
spring.dynamic.thread-pool.password=123456
# Enable server and prometheus monitoring at the same time
spring.dynamic.thread-pool.collect-type=server,prometheus
# Enable server and micrometer monitoring at the same time
spring.dynamic.thread-pool.collect-type=server,micrometer

@ -28,9 +28,9 @@ public enum MonitorTypeEnum {
LOG,
/**
* PROMETHEUS
* MICROMETER
*/
PROMETHEUS,
MICROMETER,
/**
* SERVER

@ -7,7 +7,7 @@
<artifactId>hippo4j-monitor</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-monitor-prometheus</artifactId>
<artifactId>hippo4j-monitor-micrometer</artifactId>
<dependencies>
<dependency>

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.monitor.prometheus;
package cn.hippo4j.monitor.micrometer;
import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.common.model.ThreadPoolRunStateInfo;
@ -32,9 +32,9 @@ import org.springframework.core.env.Environment;
import java.util.Map;
/**
* Prometheus monitor handler.
* Micrometer monitor handler.
*/
public class PrometheusMonitorHandler extends AbstractDynamicThreadPoolMonitor {
public class MicrometerMonitorHandler extends AbstractDynamicThreadPoolMonitor {
private final static String METRIC_NAME_PREFIX = "dynamic.thread-pool";
@ -44,7 +44,7 @@ public class PrometheusMonitorHandler extends AbstractDynamicThreadPoolMonitor {
private final Map<String, ThreadPoolRunStateInfo> RUN_STATE_CACHE = Maps.newConcurrentMap();
public PrometheusMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) {
public MicrometerMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) {
super(threadPoolRunStateHandler);
}
@ -81,6 +81,6 @@ public class PrometheusMonitorHandler extends AbstractDynamicThreadPoolMonitor {
@Override
public String getType() {
return MonitorTypeEnum.PROMETHEUS.name().toLowerCase();
return MonitorTypeEnum.MICROMETER.name().toLowerCase();
}
}

@ -14,7 +14,7 @@
<module>hippo4j-monitor-base</module>
<module>hippo4j-monitor-elasticsearch</module>
<module>hippo4j-monitor-local-log</module>
<module>hippo4j-monitor-prometheus</module>
<module>hippo4j-monitor-micrometer</module>
</modules>
<build>

@ -89,7 +89,7 @@
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-spring-boot-starter-monitor-prometheus</artifactId>
<artifactId>hippo4j-spring-boot-starter-monitor-micrometer</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>

@ -17,16 +17,15 @@
package cn.hippo4j.config.springboot.starter.config;
import java.util.List;
import java.util.Map;
import cn.hippo4j.core.config.BootstrapPropertiesInterface;
import cn.hippo4j.config.springboot.starter.parser.ConfigFileTypeEnum;
import cn.hippo4j.core.config.BootstrapPropertiesInterface;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.List;
import java.util.Map;
/**
* Bootstrap core properties.
*/
@ -53,7 +52,7 @@ public class BootstrapConfigProperties implements BootstrapPropertiesInterface {
private Boolean collect = Boolean.TRUE;
/**
* Type of collection thread pool running data. eg: log,prometheus. Multiple can be used at the same time.
* Type of collection thread pool running data. eg: log,micrometer. Multiple can be used at the same time.
*/
private String collectType;

@ -7,12 +7,12 @@
<artifactId>hippo4j-spring-boot-starter-monitor</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-spring-boot-starter-monitor-prometheus</artifactId>
<artifactId>hippo4j-spring-boot-starter-monitor-micrometer</artifactId>
<dependencies>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-monitor-prometheus</artifactId>
<artifactId>hippo4j-monitor-micrometer</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>

@ -15,21 +15,21 @@
* limitations under the License.
*/
package cn.hippo4j.springboot.starter.monitor.prometheus;
package cn.hippo4j.springboot.starter.monitor.micrometer;
import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler;
import cn.hippo4j.monitor.prometheus.PrometheusMonitorHandler;
import cn.hippo4j.monitor.micrometer.MicrometerMonitorHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Prometheus monitor auto configuration.
* Micrometer monitor auto configuration.
*/
@Configuration
public class PrometheusMonitorAutoConfiguration {
public class MicrometerMonitorAutoConfiguration {
@Bean
public PrometheusMonitorHandler prometheusMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) {
return new PrometheusMonitorHandler(threadPoolRunStateHandler);
public MicrometerMonitorHandler micrometerMonitorHandler(ThreadPoolRunStateHandler threadPoolRunStateHandler) {
return new MicrometerMonitorHandler(threadPoolRunStateHandler);
}
}

@ -1 +1 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.monitor.prometheus.PrometheusMonitorAutoConfiguration
org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.monitor.micrometer.MicrometerMonitorAutoConfiguration

@ -13,6 +13,6 @@
<modules>
<module>hippo4j-spring-boot-starter-monitor-elasticsearch</module>
<module>hippo4j-spring-boot-starter-monitor-local-log</module>
<module>hippo4j-spring-boot-starter-monitor-prometheus</module>
<module>hippo4j-spring-boot-starter-monitor-micrometer</module>
</modules>
</project>

@ -85,7 +85,7 @@ public class BootstrapProperties implements BootstrapPropertiesInterface {
private Boolean collect = true;
/**
* Type of collection thread pool running data. eg: server,prometheus. Multiple can be used at the same time.
* Type of collection thread pool running data. eg: server,micrometer. Multiple can be used at the same time.
*/
private String collectType;

@ -117,7 +117,7 @@ public class ReportingEventExecutor implements Runnable, CommandLineRunner, Disp
ThreadFactoryBuilder.builder().daemon(true).prefix("client.scheduled.collect.data").build());
Collection<DynamicThreadPoolMonitor> dynamicThreadPoolMonitors =
DynamicThreadPoolServiceLoader.getSingletonServiceInstances(DynamicThreadPoolMonitor.class);
boolean customerDynamicThreadPoolMonitorFlag = CollectionUtil.isNotEmpty(dynamicThreadPoolMonitors) || (collectType.contains(MonitorTypeEnum.PROMETHEUS.name().toLowerCase())
boolean customerDynamicThreadPoolMonitorFlag = CollectionUtil.isNotEmpty(dynamicThreadPoolMonitors) || (collectType.contains(MonitorTypeEnum.MICROMETER.name().toLowerCase())
|| collectType.contains(MonitorTypeEnum.LOG.name().toLowerCase())
|| collectType.contains(MonitorTypeEnum.ELASTICSEARCH.name().toLowerCase()));
if (customerDynamicThreadPoolMonitorFlag) {

Loading…
Cancel
Save