From a48c77c138fc9514719dce97ce618b991984f758 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Mon, 6 Feb 2023 11:25:30 +0100 Subject: [PATCH] Add name and description for metrics --- Sources/App/Management/SQLiteDatabase.swift | 5 ++++- Sources/App/Management/TableManagement.swift | 15 ++++++++++++--- Sources/App/configure.swift | 6 +++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Sources/App/Management/SQLiteDatabase.swift b/Sources/App/Management/SQLiteDatabase.swift index c50f0bd..de5513b 100644 --- a/Sources/App/Management/SQLiteDatabase.swift +++ b/Sources/App/Management/SQLiteDatabase.swift @@ -52,7 +52,10 @@ final class SQLiteDatabase { private let registeredPlayerCountMetric: Metric 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 diff --git a/Sources/App/Management/TableManagement.swift b/Sources/App/Management/TableManagement.swift index 3202c22..50cd4e7 100644 --- a/Sources/App/Management/TableManagement.swift +++ b/Sources/App/Management/TableManagement.swift @@ -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 { diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index 85edaab..62dbd8a 100644 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -16,7 +16,11 @@ public func configure(_ app: Application) throws { logMetricId: "schafkopf.log") MetricObserver.standard = monitor - let status = Metric("schafkopf.status") + let status = Metric( + "schafkopf.status", + name: "Status", + description: "The main status of the server") + status.update(.initializing) monitor.registerRoutes(app)