29 lines
655 B
Go
29 lines
655 B
Go
|
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
||
|
// Use of this source code is governed by the Drone Non-Commercial License
|
||
|
// that can be found in the LICENSE file.
|
||
|
|
||
|
package metric
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/drone/drone/core"
|
||
|
|
||
|
"github.com/prometheus/client_golang/prometheus"
|
||
|
)
|
||
|
|
||
|
var noContext = context.Background()
|
||
|
|
||
|
// UserCount provides metrics for registered users.
|
||
|
func UserCount(users core.UserStore) {
|
||
|
prometheus.MustRegister(
|
||
|
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
|
||
|
Name: "drone_user_count",
|
||
|
Help: "Total number of active users.",
|
||
|
}, func() float64 {
|
||
|
i, _ := users.Count(noContext)
|
||
|
return float64(i)
|
||
|
}),
|
||
|
)
|
||
|
}
|