diff --git a/test/instrumented-sample-app/VERSION b/test/instrumented-sample-app/VERSION index 26a023eef..7c6e9bf24 100644 --- a/test/instrumented-sample-app/VERSION +++ b/test/instrumented-sample-app/VERSION @@ -1 +1 @@ -0.2.0-bearer-mtls-1 +0.3.0-bearer-mtls-1 diff --git a/test/instrumented-sample-app/main.go b/test/instrumented-sample-app/main.go index 5b7f83bf4..b96ce60b4 100644 --- a/test/instrumented-sample-app/main.go +++ b/test/instrumented-sample-app/main.go @@ -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 = "" + } 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) {