mirror of
https://github.com/openfaas/faas.git
synced 2025-06-21 00:06:38 +00:00
Add RED metrics
- this PR adds metrics via Prometheus for instrumentation and to move towards using HPAv2 / custom metrics in Kubernetes. Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
@ -19,6 +19,7 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/openfaas/faas/watchdog/metrics"
|
||||
"github.com/openfaas/faas/watchdog/types"
|
||||
)
|
||||
|
||||
@ -58,12 +59,19 @@ func main() {
|
||||
MaxHeaderBytes: 1 << 20, // Max header of 1MB
|
||||
}
|
||||
|
||||
httpMetrics := metrics.NewHttp()
|
||||
log.Printf("Read/write timeout: %s, %s. Port: %d\n", readTimeout, writeTimeout, config.port)
|
||||
http.HandleFunc("/_/health", makeHealthHandler())
|
||||
http.HandleFunc("/", makeRequestHandler(&config))
|
||||
http.HandleFunc("/", metrics.InstrumentHandler(makeRequestHandler(&config), httpMetrics))
|
||||
|
||||
metricsServer := metrics.MetricsServer{}
|
||||
metricsServer.Register(config.metricsPort)
|
||||
|
||||
cancel := make(chan bool)
|
||||
|
||||
go metricsServer.Serve(cancel)
|
||||
|
||||
shutdownTimeout := config.writeTimeout
|
||||
|
||||
listenUntilShutdown(shutdownTimeout, s, config.suppressLock)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user