Skip to content

Commit

Permalink
added arguments to -prometheus-histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameiswhm committed Oct 23, 2017
1 parent 427e1c7 commit 1c0ade9
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions cmd/tiller/tiller.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const (
var (
grpcAddr = flag.String("listen", ":44134", "address:port to listen on")
enableTracing = flag.Bool("trace", false, "enable rpc tracing")
enableHistograms = flag.Bool("prometheus-histograms", false, "enable reporting of RPC request latencies via prometheus histograms")
prometheusHistograms = flag.String("prometheus-histograms", "", "comma-separated list of prometheus histogram bucket sizes for RPC request latencies reporting, e.g. '0.005,0.01,0.025,0.05,0.1,0.25,0.5,1,2.5,5,10'")
store = flag.String("storage", storageConfigMap, "storage driver to use. One of 'configmap', 'memory', or 'secret'")
remoteReleaseModules = flag.Bool("experimental-release", false, "enable experimental release modules")
tlsEnable = flag.Bool("tls", tlsEnableEnvVarDefault(), "enable TLS")
Expand Down Expand Up @@ -185,9 +185,10 @@ func start() {
// Register gRPC server to prometheus to initialized matrix
goprom.Register(rootServer)

if *enableHistograms {
goprom.EnableHandlingTimeHistogram()
logger.Println("Prometheus histograms reporting is enabled")
buckets := histogramBuckets()
if len(buckets) > 0 {
goprom.EnableHandlingTimeHistogram(goprom.WithHistogramBuckets(buckets))
logger.Printf("Prometheus histograms reporting is enabled with buckets %v", buckets)
}

addPrometheusHandler(mux)
Expand Down Expand Up @@ -264,3 +265,19 @@ func historyMaxFromEnv() int {

func tlsEnableEnvVarDefault() bool { return os.Getenv(tlsEnableEnvVar) != "" }
func tlsVerifyEnvVarDefault() bool { return os.Getenv(tlsVerifyEnvVar) != "" }

func histogramBuckets() []float64 {
val := strings.Split(*prometheusHistograms, ",")

buckets := []float64{}
for _, le := range val {
n, err := strconv.ParseFloat(le, 64)
if err != nil {
log.Printf("Invalid histogram bucket size: %q", le)
continue
}
buckets = append(buckets, n)
}

return buckets
}

0 comments on commit 1c0ade9

Please sign in to comment.