mirror of
https://github.com/lightninglabs/aperture.git
synced 2026-01-31 07:04:26 +01:00
multi: record the number of active mailboxes
This commit is contained in:
@@ -406,6 +406,8 @@ func (h *hashMailServer) InitStream(
|
||||
|
||||
h.streams[streamID] = freshStream
|
||||
|
||||
mailboxCount.Set(float64(len(h.streams)))
|
||||
|
||||
return &hashmailrpc.CipherInitResp{
|
||||
Resp: &hashmailrpc.CipherInitResp_Success{},
|
||||
}, nil
|
||||
@@ -478,6 +480,8 @@ func (h *hashMailServer) TearDownStream(ctx context.Context, streamID []byte,
|
||||
|
||||
delete(h.streams, sid)
|
||||
|
||||
mailboxCount.Set(float64(len(h.streams)))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,18 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
var (
|
||||
// mailboxCount tracks the current number of active mailboxes.
|
||||
mailboxCount = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: "hashmail",
|
||||
Name: "mailbox_count",
|
||||
})
|
||||
)
|
||||
|
||||
// PrometheusConfig is the set of configuration data that specifies if
|
||||
// Prometheus metric exporting is activated, and if so the listening address of
|
||||
// the Prometheus server.
|
||||
@@ -29,6 +38,7 @@ func StartPrometheusExporter(cfg *PrometheusConfig) error {
|
||||
}
|
||||
|
||||
// Next, we'll register all our metrics.
|
||||
prometheus.MustRegister(mailboxCount)
|
||||
|
||||
// Finally, we'll launch the HTTP server that Prometheus will use to
|
||||
// scape our metrics.
|
||||
|
||||
Reference in New Issue
Block a user