Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 4-governance/dubbo-samples-metrics-spring-boot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ Dubbo 支持通过两种方式对外暴露 Metrics 指标给 Prometheus,具体
* Spring-boot-actuator,即通过标准的 Spring boot actuator 端口在特定的 endpoint 将 Dubbo 监控指标暴露出去
* dubbo qos,即通过 Dubbo 内置的 qos 端口将 Dubbo 监控指标暴露出去

本示例中,我们使用 spring-boot-actuator 的方式透出 Dubbo 指标信息,请注意本示例使用的 Dubbo 版本必须为 3.2.0-beta.6 以上。
本示例基于 **Spring Boot 3 / JDK 17**,使用 spring-boot-actuator 的方式透出 Dubbo 指标信息,请注意本示例使用的 Dubbo 版本必须为 3.3.0 以上。

### Metrics 相关示例配置

```yaml
# ......
management.server.port=18081
management.endpoints.web.base-path=/management
management.prometheus.metrics.export.enabled=true
dubbo.metrics.protocol=prometheus

# 如果不使用 spring-boot-actuator,可使用下面配置开启 qos 配置
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
# Supported component versions of the test case

# Spring app
dubbo.version=[>=3.3.0]
spring.version=5.*
java.version= [>= 8]
dubbo.version=3.3.*
spring.version=6.*
java.version= [>= 17]
118 changes: 34 additions & 84 deletions 4-governance/dubbo-samples-metrics-spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>23</version>
<version>31</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -34,16 +34,14 @@
<description>Dubbo Samples Metrics</description>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<dubbo.version>3.3.1</dubbo.version>
<spring-boot.version>2.7.18</spring-boot.version>
<spring-boot.version>3.2.3</spring-boot.version>
<httpclient.version>4.5.13</httpclient.version>
<junit.version>4.13.1</junit.version>

<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
</properties>

<dependencyManagement>
Expand All @@ -64,16 +62,12 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<artifactId>log4j-to-slf4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
Expand All @@ -96,18 +90,14 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.dubbo/dubbo-metrics-prometheus -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-observability-spring-boot-starter</artifactId>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-observability-spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-zookeeper-curator5-spring-boot-starter</artifactId>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-zookeeper-curator5-spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
Expand All @@ -116,27 +106,22 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_pushgateway</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_pushgateway</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -151,11 +136,6 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand All @@ -164,10 +144,8 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
Expand All @@ -178,21 +156,6 @@
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<version>1.5.19</version>
<exclusions>
<exclusion>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>

<!-- Embedded Zookeeper Server Dependencies -->
<dependency>
Expand All @@ -205,40 +168,27 @@
<artifactId>snappy-java</artifactId>
<version>1.1.10.5</version>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
</dependency>
</dependencies>

<profiles>
<!-- For jdk 11 above JavaEE annotation -->
<profile>
<id>javax.annotation</id>
<activation>
<jdk>[1.11,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<compilerArg>-proc:none</compilerArg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.8</version>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,39 @@ management:
metrics:
tags:
application: dubbo-samples-metrics-spring-boot
export:
prometheus:
prometheus:
metrics:
export:
enabled: true
server:
port: 18081
endpoints:
web:
base-path: /management
exposure:
include: info,health,env,prometheus
include:
- health
- info
- env
- prometheus
endpoint:
metrics:
health:
enabled: true
show-details: always
info:
enabled: true
env:
enabled: true
prometheus:
enabled: true

spring:
main:
allow-circular-references: true
info:
app:
name: dubbo-samples-metrics-spring-boot
description: Dubbo metrics sample on Spring Boot 3

server:
port: 18080
Expand Down
Loading