Add name and description for metrics

This commit is contained in:
Christoph Hagen 2023-02-06 11:25:30 +01:00
parent 13f13c8503
commit a48c77c138
3 changed files with 21 additions and 5 deletions

View File

@ -52,7 +52,10 @@ final class SQLiteDatabase {
private let registeredPlayerCountMetric: Metric<Int>
init(database: Database, mail: Configuration.EMail?) {
self.registeredPlayerCountMetric = Metric("schafkopf.players")
self.registeredPlayerCountMetric = Metric(
"schafkopf.players",
name: "Number of users",
description: "The total number of user accounts")
self.tables = TableManagement(database: database)
self.mail = mail?.mailConfig

View File

@ -28,9 +28,18 @@ final class TableManagement {
- Throws: Errors when the file could not be read
*/
init(database: Database) {
self.tableCountMetric = .init("schafkopf.tables")
self.playingPlayerCountMetric = .init("schafkopf.playing")
self.connectedPlayerCountMetric = .init("schafkopf.connected")
self.tableCountMetric = .init(
"schafkopf.tables",
name: "Open tables",
description: "The number of currently available tables")
self.playingPlayerCountMetric = .init(
"schafkopf.playing",
name: "Sitting players",
description: "The number of players currently sitting at a table")
self.connectedPlayerCountMetric = .init(
"schafkopf.connected",
name: "Connected players",
description: "The number of players with a websocket connection to the server")
Task {
do {

View File

@ -16,7 +16,11 @@ public func configure(_ app: Application) throws {
logMetricId: "schafkopf.log")
MetricObserver.standard = monitor
let status = Metric<ServerStatus>("schafkopf.status")
let status = Metric<ServerStatus>(
"schafkopf.status",
name: "Status",
description: "The main status of the server")
status.update(.initializing)
monitor.registerRoutes(app)