From 3012ff84a2a2e415252e280dab61a6a73045a1ee Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 25 Jun 2022 15:10:15 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=E9=9B=86?= =?UTF-8?q?=E6=88=90=20Prometheus=20=E7=9B=91=E6=8E=A7=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao-spring-boot-starter-monitor/pom.xml | 6 ++ .../config/YudaoMetricsAutoConfiguration.java | 17 +++--- .../main/resources/META-INF/spring.factories | 3 +- 归档/common/mall-spring-boot/pom.xml | 55 ------------------- .../main/resources/META-INF/spring.factories | 2 - 5 files changed, 18 insertions(+), 65 deletions(-) rename 归档/common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/metrics/MetricsAutoConfiguration.java => yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoMetricsAutoConfiguration.java (59%) delete mode 100644 归档/common/mall-spring-boot/pom.xml delete mode 100644 归档/common/mall-spring-boot/src/main/resources/META-INF/spring.factories diff --git a/yudao-framework/yudao-spring-boot-starter-monitor/pom.xml b/yudao-framework/yudao-spring-boot-starter-monitor/pom.xml index a6d9ac8e..bc8d235b 100644 --- a/yudao-framework/yudao-spring-boot-starter-monitor/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-monitor/pom.xml @@ -58,6 +58,12 @@ apm-toolkit-opentracing + + + io.micrometer + micrometer-registry-prometheus + + de.codecentric spring-boot-admin-starter-client diff --git a/归档/common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/metrics/MetricsAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoMetricsAutoConfiguration.java similarity index 59% rename from 归档/common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/metrics/MetricsAutoConfiguration.java rename to yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoMetricsAutoConfiguration.java index b5fe3f02..cda0d2cb 100644 --- a/归档/common/mall-spring-boot/src/main/java/cn/iocoder/mall/spring/boot/metrics/MetricsAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoMetricsAutoConfiguration.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.spring.boot.metrics; +package cn.iocoder.yudao.framework.tracer.config; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.beans.factory.annotation.Value; @@ -8,16 +8,19 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +/** + * Metrics 配置类 + * + * @author 芋道源码 + */ @Configuration @ConditionalOnClass({MeterRegistryCustomizer.class}) -@ConditionalOnProperty(prefix = "management.metrics", value = "enable", matchIfMissing = true) // 允许使用 management.metrics.enable=false 禁用 Metrics -public class MetricsAutoConfiguration { - - @Value("${spring.application.name}") - private String applicationName; +@ConditionalOnProperty(prefix = "yudao.metrics", value = "enable", matchIfMissing = true) // 允许使用 yudao.metrics.enable=false 禁用 Metrics +public class YudaoMetricsAutoConfiguration { @Bean - MeterRegistryCustomizer metricsCommonTags() { + public MeterRegistryCustomizer metricsCommonTags( + @Value("${spring.application.name}") String applicationName) { return registry -> registry.config().commonTags("application", applicationName); } diff --git a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/resources/META-INF/spring.factories b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/resources/META-INF/spring.factories index 6f4f606b..9b69f01e 100644 --- a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/resources/META-INF/spring.factories +++ b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/resources/META-INF/spring.factories @@ -1,2 +1,3 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - cn.iocoder.yudao.framework.tracer.config.YudaoTracerAutoConfiguration + cn.iocoder.yudao.framework.tracer.config.YudaoTracerAutoConfiguration,\ + cn.iocoder.yudao.framework.tracer.config.YudaoMetricsAutoConfiguration diff --git a/归档/common/mall-spring-boot/pom.xml b/归档/common/mall-spring-boot/pom.xml deleted file mode 100644 index 8d36246d..00000000 --- a/归档/common/mall-spring-boot/pom.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - common - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - mall-spring-boot - - - - - cn.iocoder.mall - common-framework - 1.0-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter - - - - - org.springframework - spring-webmvc - true - - - javax.servlet - servlet-api - true - - - - - org.springframework.boot - spring-boot-actuator-autoconfigure - true - - - - io.micrometer - micrometer-registry-prometheus - true - - - - - diff --git a/归档/common/mall-spring-boot/src/main/resources/META-INF/spring.factories b/归档/common/mall-spring-boot/src/main/resources/META-INF/spring.factories deleted file mode 100644 index c2211a8c..00000000 --- a/归档/common/mall-spring-boot/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - cn.iocoder.mall.spring.boot.metrics.MetricsAutoConfiguration