File tree Expand file tree Collapse file tree 6 files changed +78
-6
lines changed
Expand file tree Collapse file tree 6 files changed +78
-6
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ cd prometheus
6+ ../gradlew shadowJar
7+ docker compose up -d
8+
9+ function ready() {
10+ # check that 200 is returned from the metrics endpoint
11+ curl -f localhost:19090/metrics > /dev/null 2>&1 || (echo " Metrics endpoint did not return 200" && exit 1)
12+ # check that 200 is returned from the Prometheus server
13+ curl -f http://localhost:9090 > /dev/null 2>&1 || (echo " Prometheus did not return 200" && exit 1)
14+ }
15+
16+ # wait up to 2 minutes for the endpoints to be ready
17+ timeout=120
18+ interval=5
19+ elapsed=0
20+ while ! ready; do
21+ if [ $elapsed -ge $timeout ]; then
22+ echo " Timeout waiting for Prometheus endpoints to be ready"
23+ docker compose logs
24+ docker compose down
25+ exit 1
26+ fi
27+ echo " Waiting for Prometheus endpoints to be ready..."
28+ sleep $interval
29+ elapsed=$(( elapsed + interval))
30+ done
31+
32+ echo " Prometheus example build and endpoints are working correctly"
33+
34+ docker compose down
Original file line number Diff line number Diff line change 1+ name : Prometheus Test
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+ paths :
8+ - .github/workflows/prometheus-test.yml
9+ - .github/scripts/prometheus-test.sh
10+ - ' prometheus/**'
11+ workflow_dispatch :
12+
13+ permissions :
14+ contents : read
15+
16+ jobs :
17+ acceptance-tests :
18+ runs-on : ubuntu-24.04
19+ steps :
20+ - name : Check out
21+ uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
22+
23+ - name : Set up JDK for running Gradle
24+ uses : actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
25+ with :
26+ distribution : temurin
27+ java-version : 17
28+
29+ - name : Set up gradle
30+ uses : gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
31+ with :
32+ cache-read-only : ${{ github.event_name == 'pull_request' }}
33+
34+ - name : Run Prometheus test
35+ run : .github/scripts/prometheus-test.sh
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ FROM eclipse-temurin:11.0.29_7-jre@sha256:5a9b558567e6a2f7fbaa5000891caf515c31db
22
33ADD build/libs/opentelemetry-examples-prometheus-*-SNAPSHOT-all.jar /app.jar
44
5- ENTRYPOINT java -cp app.jar io.opentelemetry.example.prometheus.PrometheusExample 19090
5+ ENTRYPOINT exec java -cp app.jar io.opentelemetry.example.prometheus.PrometheusExample 19090
Original file line number Diff line number Diff line change @@ -32,14 +32,18 @@ docker compose up
3232
3333## 3 - View Metrics
3434
35- To view metrics in Prometheus, navigate to:
35+ To view metrics in Prometheus (e.g. 90th percentile) , navigate to:
3636
37- http://localhost:9090/graph ?g0.range_input=15m&g0.expr=incoming_messages &g0.tab =0
37+ http://localhost:9090/query ?g0.expr=histogram_quantile%28.90%2C+sum+by%28le%29+%28rate%28super_timer_milliseconds_bucket%5B5m%5D%29%29%29&g0.show_tree=0&g0.tab=graph&g0. range_input=15m&g0.res_type=auto &g0.res_density=medium&g0.display_mode=lines&g0.show_exemplars =0
3838
3939To fetch application metrics in prometheus format, run:
40-
40+
41+ ``` shell
4142curl localhost:19090/metrics
43+ ```
4244
4345To fetch application metrics in OpenMetrics format, which includes exemplars, run:
4446
47+ ``` shell
4548curl -H ' Accept: application/openmetrics-text; version=1.0.0; charset=utf-8' localhost:19090/metrics
49+ ```
Original file line number Diff line number Diff line change 1- version : ' 3'
21services :
32 app :
43 build : ./
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ alerting:
88 - targets : []
99 scheme : http
1010 timeout : 10s
11- api_version : v1
11+ api_version : v2
1212scrape_configs :
1313- job_name : prometheus
1414 honor_timestamps : true
You can’t perform that action at this time.
0 commit comments