Skip to content

Commit fcda525

Browse files
authored
Add module dubbo-samples-metrics-prometheus-springboot3 with sanitized metric name to test prometheus 1.15.8 with jdk17+ (#1292)
1 parent 1952d57 commit fcda525

27 files changed

Lines changed: 2316 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 使用Metrics模块进行数据采集然后暴漏数据给普罗米修斯监控
2+
Dubbo使用开源的[Dubbo Metrics](https://github.com/alibaba/metrics)进行数据埋点,并且通过服务暴露,使用的时候,首先需要进行配置:
3+
4+
* 依赖(其中Dubbo版本在3.2.0及以后)
5+
```xml
6+
<dependency>
7+
<groupId>org.apache.dubbo</groupId>
8+
<artifactId>dubbo-spring-boot-observability-starter</artifactId>
9+
</dependency>
10+
11+
```
12+
* 服务端
13+
```xml
14+
<dubbo:metrics protocol="prometheus">
15+
<dubbo:aggregation enabled="true"/>
16+
</dubbo:metrics>
17+
18+
```
19+
20+
* 客户端
21+
```xml
22+
<dubbo:metrics protocol="prometheus">
23+
<dubbo:aggregation enabled="true"/>
24+
</dubbo:metrics>
25+
26+
```
27+
先启动服务端,然后启动客户端,
28+
提供端监控指标:http://localhost:20888/metrics
29+
消费端监控指标:http://localhost:20889/metrics
30+
31+
32+
可观测性文档如下链接:
33+
[https://cn.dubbo.apache.org/zh-cn/overview/tasks/observability/metrics-start/](https://cn.dubbo.apache.org/zh-cn/overview/tasks/observability/metrics-start/)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
services:
18+
metrics-prometheus-provider-springboot3:
19+
type: app
20+
basedir: dubbo-samples-metrics-prometheus-provider-springboot3
21+
mainClass: org.apache.dubbo.samples.metrics.prometheus.provider.MetricsProvider
22+
23+
metrics-prometheus-consumer-springboot3:
24+
type: test
25+
basedir: dubbo-samples-metrics-prometheus-consumer-springboot3
26+
tests:
27+
- "**/*IT.class"
28+
systemProps:
29+
- zookeeper.address=metrics-prometheus-provider-springboot3
30+
- zookeeper.port=2181
31+
- dubbo.address=metrics-prometheus-provider-springboot3
32+
- dubbo.port=20880
33+
waitPortsBeforeRun:
34+
- metrics-prometheus-provider-springboot3:2181
35+
- metrics-prometheus-provider-springboot3:20880
36+
depends_on:
37+
- metrics-prometheus-provider-springboot3
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
20+
# Supported component versions of the test case
21+
22+
# Spring app
23+
dubbo.version=[ >= 3.3.7 ]
24+
spring.version=6.*
25+
java.version= [>= 17]
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<parent>
22+
<groupId>org.apache.dubbo</groupId>
23+
<artifactId>dubbo-samples-metrics-prometheus-springboot3</artifactId>
24+
<version>1.0-SNAPSHOT</version>
25+
</parent>
26+
27+
<artifactId>dubbo-samples-metrics-prometheus-consumer-springboot3</artifactId>
28+
<name>dubbo-samples-metrics-prometheus-consumer-springboot3</name>
29+
30+
<dependencies>
31+
<dependency>
32+
<groupId>org.apache.dubbo</groupId>
33+
<artifactId>dubbo-zookeeper-curator5-spring-boot-starter</artifactId>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>org.apache.dubbo</groupId>
38+
<artifactId>dubbo-samples-metrics-prometheus-interface-springboot3</artifactId>
39+
<version>${project.parent.version}</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.springframework.boot</groupId>
43+
<artifactId>spring-boot-starter-test</artifactId>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.apache.httpcomponents</groupId>
48+
<artifactId>httpclient</artifactId>
49+
<scope>test</scope>
50+
</dependency>
51+
52+
<dependency>
53+
<groupId>io.dropwizard.metrics</groupId>
54+
<artifactId>metrics-core</artifactId>
55+
<version>4.1.12.1</version>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.xerial.snappy</groupId>
59+
<artifactId>snappy-java</artifactId>
60+
<version>1.1.10.5</version>
61+
</dependency>
62+
63+
<dependency>
64+
<groupId>io.micrometer</groupId>
65+
<artifactId>micrometer-registry-prometheus</artifactId>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.apache.dubbo</groupId>
69+
<artifactId>dubbo-metrics-prometheus</artifactId>
70+
</dependency>
71+
</dependencies>
72+
73+
<build>
74+
<plugins>
75+
<plugin>
76+
<groupId>org.springframework.boot</groupId>
77+
<artifactId>spring-boot-maven-plugin</artifactId>
78+
<version>2.6.14</version>
79+
<configuration>
80+
<mainClass>org.apache.dubbo.samples.metrics.prometheus.consumer.MetricsConsumer</mainClass>
81+
</configuration>
82+
<executions>
83+
<execution>
84+
<goals>
85+
<goal>repackage</goal>
86+
</goals>
87+
</execution>
88+
</executions>
89+
</plugin>
90+
<plugin>
91+
<groupId>org.apache.maven.plugins</groupId>
92+
<artifactId>maven-antrun-plugin</artifactId>
93+
<executions>
94+
<execution>
95+
<id>copy-jar-file</id>
96+
<phase>package</phase>
97+
<goals>
98+
<goal>run</goal>
99+
</goals>
100+
<configuration>
101+
<target>
102+
<copy file="target/dubbo-samples-metrics-prometheus-consumer-springboot3-1.0-SNAPSHOT.jar" tofile="target/consumer.jar"></copy>
103+
</target>
104+
</configuration>
105+
</execution>
106+
</executions>
107+
</plugin>
108+
</plugins>
109+
</build>
110+
</project>

0 commit comments

Comments
 (0)