@@ -39,6 +39,24 @@ import (
39
39
var defaultMetricPath = "/metrics"
40
40
var defaultSubsystem = "echo"
41
41
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
+
42
60
// Standard default metrics
43
61
// counter, counter_vec, gauge, gauge_vec,
44
62
// histogram, histogram_vec, summary, summary_vec
@@ -54,21 +72,24 @@ var reqDur = &Metric{
54
72
Name : "request_duration_seconds" ,
55
73
Description : "The HTTP request latencies in seconds." ,
56
74
Args : []string {"code" , "method" , "url" },
57
- Type : "histogram_vec" }
75
+ Type : "histogram_vec" ,
76
+ Buckets : reqDurBuckets }
58
77
59
78
var resSz = & Metric {
60
79
ID : "resSz" ,
61
80
Name : "response_size_bytes" ,
62
81
Description : "The HTTP response sizes in bytes." ,
63
82
Args : []string {"code" , "method" , "url" },
64
- Type : "histogram_vec" }
83
+ Type : "histogram_vec" ,
84
+ Buckets : resSzBuckets }
65
85
66
86
var reqSz = & Metric {
67
87
ID : "reqSz" ,
68
88
Name : "request_size_bytes" ,
69
89
Description : "The HTTP request sizes in bytes." ,
70
90
Args : []string {"code" , "method" , "url" },
71
- Type : "histogram_vec" }
91
+ Type : "histogram_vec" ,
92
+ Buckets : reqSzBuckets }
72
93
73
94
var standardMetrics = []* Metric {
74
95
reqCnt ,
@@ -108,6 +129,7 @@ type Metric struct {
108
129
Description string
109
130
Type string
110
131
Args []string
132
+ Buckets []float64
111
133
}
112
134
113
135
// Prometheus contains the metrics gathered by the instance and its path
@@ -307,6 +329,7 @@ func NewMetric(m *Metric, subsystem string) prometheus.Collector {
307
329
Subsystem : subsystem ,
308
330
Name : m .Name ,
309
331
Help : m .Description ,
332
+ Buckets : m .Buckets ,
310
333
},
311
334
m .Args ,
312
335
)
@@ -316,6 +339,7 @@ func NewMetric(m *Metric, subsystem string) prometheus.Collector {
316
339
Subsystem : subsystem ,
317
340
Name : m .Name ,
318
341
Help : m .Description ,
342
+ Buckets : m .Buckets ,
319
343
},
320
344
)
321
345
case "summary_vec" :
0 commit comments