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> private let registeredPlayerCountMetric: Metric<Int>
init(database: Database, mail: Configuration.EMail?) { 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.tables = TableManagement(database: database)
self.mail = mail?.mailConfig self.mail = mail?.mailConfig

View File

@ -28,9 +28,18 @@ final class TableManagement {
- Throws: Errors when the file could not be read - Throws: Errors when the file could not be read
*/ */
init(database: Database) { init(database: Database) {
self.tableCountMetric = .init("schafkopf.tables") self.tableCountMetric = .init(
self.playingPlayerCountMetric = .init("schafkopf.playing") "schafkopf.tables",
self.connectedPlayerCountMetric = .init("schafkopf.connected") 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 { Task {
do { do {

View File

@ -16,7 +16,11 @@ public func configure(_ app: Application) throws {
logMetricId: "schafkopf.log") logMetricId: "schafkopf.log")
MetricObserver.standard = monitor 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) status.update(.initializing)
monitor.registerRoutes(app) monitor.registerRoutes(app)