forked from electricdusk/rushlink
Put existing pages in templates
This commit is contained in:
@@ -23,20 +23,20 @@ func StartMetricsServer() {
|
||||
var (
|
||||
_ = promauto.NewGaugeFunc(prometheus.GaugeOpts{
|
||||
Namespace: "rushlink",
|
||||
Subsystem: "shorten",
|
||||
Subsystem: "pastes",
|
||||
Name: "urls_total",
|
||||
Help: "The current amount of shortened urls in the database.",
|
||||
Help: "The current amount of pastes in the database.",
|
||||
}, func() float64 {
|
||||
var metric float64
|
||||
if err := db.DB.View(func(tx *bolt.Tx) error {
|
||||
bucket := tx.Bucket([]byte("shorten"))
|
||||
bucket := tx.Bucket([]byte("pastes"))
|
||||
if bucket == nil {
|
||||
return errors.New("bucket 'shorten' could not be found")
|
||||
return errors.New("bucket 'pastes' could not be found")
|
||||
}
|
||||
metric = float64(bucket.Stats().KeyN)
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Printf("error: %v", errors.Wrap(err, "fetching shorten_urls_total metric"))
|
||||
log.Printf("error: %v", errors.Wrap(err, "fetching pastes_total metric"))
|
||||
return 0
|
||||
}
|
||||
return metric
|
||||
|
||||
Reference in New Issue
Block a user