mirror of
https://github.com/coreos/prometheus-operator.git
synced 2026-02-05 15:46:31 +01:00
test: expose UTF-8 metric with instrumented app
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
0.2.0-bearer-mtls-1
|
||||
0.3.0-bearer-mtls-1
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user