feat(exporter): --profile flag to run pprof server on :6060

This commit is contained in:
Arthur Chaloin
2022-06-01 13:43:39 +02:00
parent 78dd9b9940
commit 765ace4cd9
+8
View File
@@ -3,6 +3,8 @@ package main
import (
"fmt"
"math/rand"
"net/http"
_ "net/http/pprof"
"os"
"path"
"strings"
@@ -22,6 +24,7 @@ func main() {
exposeRelativeMetrics := getopt.BoolLong("expose-relative-metrics", 0, "expose additionnal metrics with relative durations instead of absolute timestamps")
exposeErrorMetrics := getopt.BoolLong("expose-per-cert-error-metrics", 0, "expose additionnal error metric for each certificate indicating wether it has failure(s)")
exposeLabels := getopt.StringLong("expose-labels", 'l', "one or more comma-separated labels to enable (defaults to all if not specified)")
profile := getopt.BoolLong("profile", 0, "optionally enable a pprof server to monitor cpu and memory usage at runtime")
maxCacheDuration := durationFlag(0)
getopt.FlagLong(&maxCacheDuration, "max-cache-duration", 0, "maximum cache duration for kube secrets. cache is per namespace and randomized to avoid massive requests.")
@@ -68,6 +71,11 @@ func main() {
log.SetLevel(log.DebugLevel)
}
if *profile {
log.Infoln("pprof server listening on :6060")
go http.ListenAndServe(":6060", nil)
}
exporter := internal.Exporter{
ListenAddress: *listenAddress,
Files: files,