refactor(metrics): 为指标增加 namespace 名称.

遵循 OpenMetrics 规范指南, 为运行指标添加 namespace 名称, 防止指标混乱.

BREAKING CHANGE: 运行指标名称变更,
如果用户启用了运行指标功能, 请注意修改使用指标的名称.
This commit is contained in:
LamGC 2022-10-28 01:33:03 +08:00
parent 6e5cd07c51
commit c94e0476b5
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D
2 changed files with 6 additions and 0 deletions

View File

@ -250,6 +250,7 @@ internal class LogDirectorySupplier : PropertyDefinerBase() {
internal object Const {
val config = loadAppConfig()
const val METRICS_NAMESPACE = "scalabot"
}
private fun AppPaths.defaultInitializer() {

View File

@ -135,6 +135,7 @@ internal class ScalaBot(
.name("updates_total")
.help("Total number of updates received by all bots.")
.labelNames("bot_name")
.namespace(Const.METRICS_NAMESPACE)
.subsystem("telegrambots")
.register()
@ -143,6 +144,7 @@ internal class ScalaBot(
.name("updates_in_progress")
.help("Number of updates in process by all bots.")
.labelNames("bot_name")
.namespace(Const.METRICS_NAMESPACE)
.subsystem("telegrambots")
.register()
@ -150,6 +152,7 @@ internal class ScalaBot(
private val onlineBotGauge = Gauge.build()
.name("bots_online")
.help("Number of bots Online.")
.namespace(Const.METRICS_NAMESPACE)
.subsystem("telegrambots")
.register()
@ -162,6 +165,7 @@ internal class ScalaBot(
"It is not recommended to use it as the accurate execution time of ability)"
)
.labelNames("bot_name")
.namespace(Const.METRICS_NAMESPACE)
.subsystem("telegrambots")
.register()
@ -170,6 +174,7 @@ internal class ScalaBot(
.name("updates_exception_handling")
.help("Number of exceptions during processing.")
.labelNames("bot_name")
.namespace(Const.METRICS_NAMESPACE)
.subsystem("telegrambots")
.register()
}