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

@@ -15,6 +15,7 @@ import (
"github.com/drakkan/sftpgo/dataprovider"
"github.com/drakkan/sftpgo/logger"
"github.com/drakkan/sftpgo/metrics"
"github.com/drakkan/sftpgo/utils"
)
@@ -265,6 +266,7 @@ func addConnection(id string, c Connection) {
mutex.Lock()
defer mutex.Unlock()
openConnections[id] = c
metrics.UpdateActiveConnectionsSize(len(openConnections))
c.Log(logger.LevelDebug, logSender, "connection added, num open connections: %v", len(openConnections))
}
@@ -273,6 +275,7 @@ func removeConnection(id string) {
defer mutex.Unlock()
c := openConnections[id]
delete(openConnections, id)
metrics.UpdateActiveConnectionsSize(len(openConnections))
c.Log(logger.LevelDebug, logSender, "connection removed, num open connections: %v", len(openConnections))
}