summaryrefslogtreecommitdiff
path: root/sw-server/src
diff options
context:
space:
mode:
Diffstat (limited to 'sw-server/src')
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/SevenWonders.kt14
1 files changed, 13 insertions, 1 deletions
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/SevenWonders.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/SevenWonders.kt
index 923ebcb5..93ff0be7 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/SevenWonders.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/SevenWonders.kt
@@ -21,7 +21,19 @@ class SevenWonders {
fun metricsCommonTags(): MeterRegistryCustomizer<MeterRegistry>? = MeterRegistryCustomizer { registry ->
registry.config()
.commonTags("application", "seven-wonders")
- .commonTags("instance", InetAddress.getLocalHost().hostAddress)
+ .commonTags("instance", findInstanceName())
+ }
+
+ private fun findInstanceName(): String? {
+ val hostname = System.getenv("HOSTNAME")?.takeIf { it.isNotBlank() }
+ if (hostname != null) {
+ return hostname
+ }
+ val computerName = System.getenv("COMPUTERNAME")?.takeIf { it.isNotBlank() }
+ if (computerName != null) {
+ return computerName
+ }
+ return InetAddress.getLocalHost().hostName
}
}
bgstack15