1
0
mirror of https://github.com/coreos/prometheus-operator.git synced 2026-02-05 06:45:27 +01:00

test: expose UTF-8 metric with instrumented app

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier
2025-09-29 15:59:12 +02:00
parent 6954e4eefc
commit 07cfc8b26d
2 changed files with 19 additions and 1 deletions

View File

@@ -1 +1 @@
0.2.0-bearer-mtls-1
0.3.0-bearer-mtls-1

View File

@@ -27,6 +27,7 @@ import (
"strings"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
@@ -36,6 +37,10 @@ var (
func main() {
flag.Parse()
version := os.Getenv("VERSION")
if version == "" {
version = "<unknown>"
}
if *certPath != "" {
go func() {
@@ -43,6 +48,19 @@ func main() {
}()
}
// Expose a metric with UTF-8 name and label name.
// Depending on the Prometheus version and configuration, the metric will
// be ingested as-is or the dot characters will be escaped.
g := prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "app.info",
Help: "Application information",
ConstLabels: map[string]string{"app.version": version},
},
)
g.Set(1)
_ = prometheus.DefaultRegisterer.Register(g)
http.HandleFunc("/", handler)
http.HandleFunc("/metrics", func(w http.ResponseWriter, r *http.Request) {
if checkBasicAuth(w, r) {