add Prometheus support

some basic counters and gauges are now exposed
This commit is contained in:
Nicola Murino
2019-09-13 18:45:36 +02:00
parent fd59f35108
commit 7eb5b01169
17 changed files with 377 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ import (
"net/http"
"time"
"github.com/drakkan/sftpgo/metrics"
"github.com/go-chi/chi/middleware"
"github.com/rs/zerolog"
)
@@ -54,6 +55,7 @@ func (l *StructuredLogger) NewLogEntry(r *http.Request) middleware.LogEntry {
// Write logs a new entry at the end of the HTTP request
func (l *StructuredLoggerEntry) Write(status, bytes int, elapsed time.Duration) {
metrics.HTTPRequestServed(status)
l.Logger.Info().Fields(l.fields).Int(
"resp_status", status).Int(
"resp_size", bytes).Int64(