@@ -60,7 +60,13 @@ type TLSConfig struct {
60
60
61
61
// Config for a Server
62
62
type Config struct {
63
- MetricsNamespace string `yaml:"-"`
63
+ MetricsNamespace string `yaml:"-"`
64
+ // Set to > 1 to add native histograms to requestDuration.
65
+ // See documentation for NativeHistogramBucketFactor in
66
+ // https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#HistogramOpts
67
+ // for details. A generally useful value is 1.1.
68
+ MetricsNativeHistogramFactor float64 `yaml:"-"`
69
+
64
70
HTTPListenNetwork string `yaml:"http_listen_network"`
65
71
HTTPListenAddress string `yaml:"http_listen_address"`
66
72
HTTPListenPort int `yaml:"http_listen_port"`
@@ -292,10 +298,13 @@ func New(cfg Config) (*Server, error) {
292
298
293
299
// Prometheus histograms for requests.
294
300
requestDuration := prometheus .NewHistogramVec (prometheus.HistogramOpts {
295
- Namespace : cfg .MetricsNamespace ,
296
- Name : "request_duration_seconds" ,
297
- Help : "Time (in seconds) spent serving HTTP requests." ,
298
- Buckets : instrument .DefBuckets ,
301
+ Namespace : cfg .MetricsNamespace ,
302
+ Name : "request_duration_seconds" ,
303
+ Help : "Time (in seconds) spent serving HTTP requests." ,
304
+ Buckets : instrument .DefBuckets ,
305
+ NativeHistogramBucketFactor : cfg .MetricsNativeHistogramFactor ,
306
+ NativeHistogramMaxBucketNumber : 100 ,
307
+ NativeHistogramMinResetDuration : time .Hour ,
299
308
}, []string {"method" , "route" , "status_code" , "ws" })
300
309
reg .MustRegister (requestDuration )
301
310
0 commit comments