Implemented admin pane + user permission
This commit is contained in:
@@ -38,6 +38,30 @@ func IncWrites() { writeOps.Add(1) }
|
||||
// IncHistoryReqs increments the history request counter.
|
||||
func IncHistoryReqs() { historyReqs.Add(1) }
|
||||
|
||||
// Stats is a point-in-time snapshot of the in-process counters, for rendering
|
||||
// as JSON in the admin pane (the Prometheus Handler renders the same data as
|
||||
// text).
|
||||
type Stats struct {
|
||||
UptimeSeconds float64 `json:"uptimeSeconds"`
|
||||
WsConnections int64 `json:"wsConnections"`
|
||||
MsgIn int64 `json:"msgIn"`
|
||||
MsgOut int64 `json:"msgOut"`
|
||||
WriteOps int64 `json:"writeOps"`
|
||||
HistoryReqs int64 `json:"historyReqs"`
|
||||
}
|
||||
|
||||
// Snapshot returns the current values of all counters and gauges.
|
||||
func Snapshot() Stats {
|
||||
return Stats{
|
||||
UptimeSeconds: time.Since(startTime).Seconds(),
|
||||
WsConnections: wsConns.Load(),
|
||||
MsgIn: msgIn.Load(),
|
||||
MsgOut: msgOut.Load(),
|
||||
WriteOps: writeOps.Load(),
|
||||
HistoryReqs: historyReqs.Load(),
|
||||
}
|
||||
}
|
||||
|
||||
// Handler returns an http.HandlerFunc that renders Prometheus-format metrics.
|
||||
// activeSubs is called each request to read the current number of unique signal
|
||||
// subscriptions from the broker; pass nil to omit the metric.
|
||||
|
||||
Reference in New Issue
Block a user