@@ -39,6 +39,24 @@ import (
3939var defaultMetricPath = "/metrics"
4040var defaultSubsystem = "echo"
4141
42+ const (
43+ _ = iota // ignore first value by assigning to blank identifier
44+ KB float64 = 1 << (10 * iota )
45+ MB
46+ GB
47+ TB
48+ )
49+
50+ // reqDurBuckets is the buckets for request duration. Here, we use the prometheus defaults
51+ // which are for ~10s request length max: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10}
52+ var reqDurBuckets = prometheus .DefBuckets
53+
54+ // reqSzBuckets is the buckets for request size. Here we define a spectrom from 1KB thru 1NB up to 10MB.
55+ var reqSzBuckets = []float64 {1.0 * KB , 2.0 * KB , 5.0 * KB , 10.0 * KB , 100 * KB , 500 * KB , 1.0 * MB , 2.5 * MB , 5.0 * MB , 10.0 * MB }
56+
57+ // resSzBuckets is the buckets for response size. Here we define a spectrom from 1KB thru 1NB up to 10MB.
58+ var resSzBuckets = []float64 {1.0 * KB , 2.0 * KB , 5.0 * KB , 10.0 * KB , 100 * KB , 500 * KB , 1.0 * MB , 2.5 * MB , 5.0 * MB , 10.0 * MB }
59+
4260// Standard default metrics
4361// counter, counter_vec, gauge, gauge_vec,
4462// histogram, histogram_vec, summary, summary_vec
@@ -54,21 +72,24 @@ var reqDur = &Metric{
5472 Name : "request_duration_seconds" ,
5573 Description : "The HTTP request latencies in seconds." ,
5674 Args : []string {"code" , "method" , "url" },
57- Type : "histogram_vec" }
75+ Type : "histogram_vec" ,
76+ Buckets : reqDurBuckets }
5877
5978var resSz = & Metric {
6079 ID : "resSz" ,
6180 Name : "response_size_bytes" ,
6281 Description : "The HTTP response sizes in bytes." ,
6382 Args : []string {"code" , "method" , "url" },
64- Type : "histogram_vec" }
83+ Type : "histogram_vec" ,
84+ Buckets : resSzBuckets }
6585
6686var reqSz = & Metric {
6787 ID : "reqSz" ,
6888 Name : "request_size_bytes" ,
6989 Description : "The HTTP request sizes in bytes." ,
7090 Args : []string {"code" , "method" , "url" },
71- Type : "histogram_vec" }
91+ Type : "histogram_vec" ,
92+ Buckets : reqSzBuckets }
7293
7394var standardMetrics = []* Metric {
7495 reqCnt ,
@@ -108,6 +129,7 @@ type Metric struct {
108129 Description string
109130 Type string
110131 Args []string
132+ Buckets []float64
111133}
112134
113135// Prometheus contains the metrics gathered by the instance and its path
@@ -307,6 +329,7 @@ func NewMetric(m *Metric, subsystem string) prometheus.Collector {
307329 Subsystem : subsystem ,
308330 Name : m .Name ,
309331 Help : m .Description ,
332+ Buckets : m .Buckets ,
310333 },
311334 m .Args ,
312335 )
@@ -316,6 +339,7 @@ func NewMetric(m *Metric, subsystem string) prometheus.Collector {
316339 Subsystem : subsystem ,
317340 Name : m .Name ,
318341 Help : m .Description ,
342+ Buckets : m .Buckets ,
319343 },
320344 )
321345 case "summary_vec" :
0 commit comments