Skip to content

Commit

Permalink
feat: add promethus metrics support (#25)
Browse files Browse the repository at this point in the history
Co-authored-by: rick <[email protected]>
  • Loading branch information
LinuxSuRen and LinuxSuRen authored Apr 23, 2024
1 parent c1ee067 commit 6be6ecd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Run E2E testing:
make build-image test-e2e
```

Run with Maven command:

```shell
mvn spring-boot:run
```

## OpenAPI definition
You can visit it via: http://localhost:8080/v3/api-docs

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

## tRPC
The [tRPC](https://github.com/trpc-group/trpc-java) endpoint is: `http://localhost:9090`

## Metrics
You can visit the metrics endpoint: `/actuator/prometheus`
5 changes: 5 additions & 0 deletions e2e/test-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@ items:
expect:
bodyFieldsExpect:
message: rick
- name: prometheus
request:
api: /actuator/prometheus
header:
Authorization: "{{ .param.auth }}"
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@
<version>1.1.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/github/devopsws/demo/DemoApplication.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.devopsws.demo;

import com.tencent.trpc.spring.boot.starters.annotation.EnableTRpc;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ trpc:
ip: 0.0.0.0 # Listen ip
port: 9090 # Listen port
network: tcp # Network type, tcp or udp

# https://spring.academy/guides/spring-spring-prometheus
management:
endpoints:
web:
exposure:
include: health, metrics, prometheus
metrics:
tags:
application: ${spring.application.name}

0 comments on commit 6be6ecd

Please sign in to comment.