Put existing pages in templates

This commit is contained in:
Daan Sprenkels
2019-09-15 22:54:07 +02:00
parent 372d7c0487
commit 60fd92c956
7 changed files with 69 additions and 52 deletions

View File

@@ -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