From b05177a55370cd3f5e11450619a31b3ccbfa2e2b Mon Sep 17 00:00:00 2001 From: alissa-tung Date: Wed, 16 Mar 2022 17:46:48 +0800 Subject: [PATCH 1/2] Fix deprecated `NewBuildInfoCollector` API Update `examples/random/main.go`: `prometheus.NewBuildInfoCollector` is deprecated. Use `collectors.NewBuildInfoCollector` instead. Signed-off-by: alissa-tung --- examples/random/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/random/main.go b/examples/random/main.go index cf44863..1321423 100644 --- a/examples/random/main.go +++ b/examples/random/main.go @@ -26,6 +26,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/collectors" "github.com/prometheus/client_golang/prometheus/promhttp" ) @@ -67,7 +68,7 @@ func main() { prometheus.MustRegister(rpcDurations) prometheus.MustRegister(rpcDurationsHistogram) // Add Go module build info. - prometheus.MustRegister(prometheus.NewBuildInfoCollector()) + prometheus.MustRegister(collectors.NewBuildInfoCollector()) start := time.Now() From ffd6362a06df307874df9230b3e9394d9b037523 Mon Sep 17 00:00:00 2001 From: alissa-tung Date: Wed, 16 Mar 2022 18:14:51 +0800 Subject: [PATCH 2/2] Update Dockerfile example Signed-off-by: alissa-tung Co-authored-by: Cruise_Hua --- Dockerfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4da5f16..2627ff4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,15 @@ # This Dockerfile builds an image for a client_golang example. # # Use as (from the root for the client_golang repository): -# docker build -f examples/$name/Dockerfile -t prometheus/golang-example-$name . +# docker build -f Dockerfile -t prometheus/golang-example . + +# Run as +# docker run -P prometheus/golang-example /random +# or +# docker run -P prometheus/golang-example /simple + +# Test as +# curl $ip:$port/metrics # Builder image, where we build the example. FROM golang:1 AS builder