-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from FachschaftMathPhysInfo/prometheus-metrics
Prometheus Metrics
- Loading branch information
Showing
3 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package utils | ||
|
||
import ( | ||
"github.com/FachschaftMathPhysInfo/altklausur-ausleihe/server/graph/model" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
"gorm.io/gorm" | ||
) | ||
|
||
var ( | ||
// ExamsMarkedMetric is a prometheus metric for the amount of requested exams for watermarking | ||
ExamsMarkedMetric = promauto.NewCounter(prometheus.CounterOpts{ | ||
Name: "altklausur_ausleihe_exams_marked", | ||
Help: "The total number of requested exams", | ||
}) | ||
|
||
// TotalExamsMetric is a prometheus metric for the total amount of exams in the database | ||
TotalExamsMetric = promauto.NewGauge(prometheus.GaugeOpts{ | ||
Name: "altklausur_ausleihe_exams_total", | ||
Help: "The total number of exams", | ||
}) | ||
) | ||
|
||
// UpdateTotalExamsMetric updates the TotalExamsMetric with the current value from the database | ||
func UpdateTotalExamsMetric(database *gorm.DB) { | ||
var count int64 | ||
database.Model(&model.Exam{}).Count(&count) | ||
TotalExamsMetric.Set(float64(count)) | ||
} |