summaryrefslogtreecommitdiff
path: root/service/metrics
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-03-26 19:27:16 +0300
committerValery Piashchynski <[email protected]>2020-03-26 19:27:16 +0300
commitcbde9a2001657ae6a8e73e1a01dad6e660c2fc0a (patch)
treebcaff1553c179f0e8db5159c5b692cf5de908e11 /service/metrics
parent7b2e5d9ffcffd539cbff431855b775f1f8901f73 (diff)
Update servers timeouts and max header sizes [health, metrics]
Diffstat (limited to 'service/metrics')
-rw-r--r--service/metrics/service.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/service/metrics/service.go b/service/metrics/service.go
index 6fa4da50..0b667f2d 100644
--- a/service/metrics/service.go
+++ b/service/metrics/service.go
@@ -11,10 +11,15 @@ import (
"github.com/spiral/roadrunner/service/rpc"
"net/http"
"sync"
+ "time"
)
-// ID declares public service name.
-const ID = "metrics"
+const (
+ // ID declares public service name.
+ ID = "metrics"
+ // maxHeaderSize declares max header size for prometheus server
+ maxHeaderSize = 1024 * 1024 * 100 // 104MB
+)
// Service to manage application metrics using Prometheus.
type Service struct {
@@ -76,18 +81,23 @@ func (s *Service) Serve() error {
}
s.mu.Lock()
- s.http = &http.Server{Addr: s.cfg.Address, Handler: promhttp.HandlerFor(
- s.registry,
- promhttp.HandlerOpts{},
- )}
+ s.http = &http.Server{
+ Addr: s.cfg.Address,
+ Handler: promhttp.HandlerFor(s.registry, promhttp.HandlerOpts{}, ),
+ IdleTimeout: time.Hour * 24,
+ ReadTimeout: time.Minute * 60,
+ MaxHeaderBytes: maxHeaderSize,
+ ReadHeaderTimeout: time.Minute * 60,
+ WriteTimeout: time.Minute * 60,
+ }
s.mu.Unlock()
err = s.http.ListenAndServe()
- if err == nil || err == http.ErrServerClosed {
- return nil
+ if err != nil && err != http.ErrServerClosed {
+ return err
}
- return err
+ return nil
}
// Stop prometheus metrics service.