Examples: Replace deprecated WithGoCollections with WithGoCollectorRuntimeMetrics (#1130)

Signed-off-by: rogerogers <rogers@rogerogers.com>

Signed-off-by: rogerogers <rogers@rogerogers.com>
This commit is contained in:
rogerogers 2022-09-12 17:24:20 +08:00 committed by GitHub
parent 7c46c150bd
commit 9801a4e3ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import (
"fmt" "fmt"
"log" "log"
"net/http" "net/http"
"regexp"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors" "github.com/prometheus/client_golang/prometheus/collectors"
@ -39,7 +40,7 @@ func main() {
// Add Go module build info. // Add Go module build info.
reg.MustRegister(collectors.NewBuildInfoCollector()) reg.MustRegister(collectors.NewBuildInfoCollector())
reg.MustRegister(collectors.NewGoCollector( reg.MustRegister(collectors.NewGoCollector(
collectors.WithGoCollections(collectors.GoRuntimeMemStatsCollection | collectors.GoRuntimeMetricsCollection), collectors.WithGoCollectorRuntimeMetrics(collectors.GoRuntimeMetricsRule{Matcher: regexp.MustCompile("/.*")}),
)) ))
// Expose the registered metrics via HTTP. // Expose the registered metrics via HTTP.