Skip to content

Commit 6be6ecd

Browse files
authored
feat: add promethus metrics support (#25)
Co-authored-by: rick <LinuxSuRen@users.noreply.github.com>
1 parent c1ee067 commit 6be6ecd

5 files changed

Lines changed: 34 additions & 0 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ Run E2E testing:
77
make build-image test-e2e
88
```
99

10+
Run with Maven command:
11+
12+
```shell
13+
mvn spring-boot:run
14+
```
15+
1016
## OpenAPI definition
1117
You can visit it via: http://localhost:8080/v3/api-docs
1218

@@ -17,3 +23,6 @@ You can visit it via: http://localhost:8080/graphiql?path=/graphql
1723

1824
## tRPC
1925
The [tRPC](https://github.com/trpc-group/trpc-java) endpoint is: `http://localhost:9090`
26+
27+
## Metrics
28+
You can visit the metrics endpoint: `/actuator/prometheus`

e2e/test-suite.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,8 @@ items:
9494
expect:
9595
bodyFieldsExpect:
9696
message: rick
97+
- name: prometheus
98+
request:
99+
api: /actuator/prometheus
100+
header:
101+
Authorization: "{{ .param.auth }}"

pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@
4747
<version>1.1.0</version>
4848
</dependency>
4949

50+
<dependency>
51+
<groupId>org.springframework.boot</groupId>
52+
<artifactId>spring-boot-starter-actuator</artifactId>
53+
</dependency>
54+
<dependency>
55+
<groupId>io.micrometer</groupId>
56+
<artifactId>micrometer-registry-prometheus</artifactId>
57+
</dependency>
58+
5059
<dependency>
5160
<groupId>org.springframework.boot</groupId>
5261
<artifactId>spring-boot-starter-test</artifactId>

src/main/java/io/github/devopsws/demo/DemoApplication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.devopsws.demo;
22

33
import com.tencent.trpc.spring.boot.starters.annotation.EnableTRpc;
4+
45
import org.springframework.boot.SpringApplication;
56
import org.springframework.boot.autoconfigure.SpringBootApplication;
67

src/main/resources/application.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,13 @@ trpc:
1919
ip: 0.0.0.0 # Listen ip
2020
port: 9090 # Listen port
2121
network: tcp # Network type, tcp or udp
22+
23+
# https://spring.academy/guides/spring-spring-prometheus
24+
management:
25+
endpoints:
26+
web:
27+
exposure:
28+
include: health, metrics, prometheus
29+
metrics:
30+
tags:
31+
application: ${spring.application.name}

0 commit comments

Comments
 (0)