lib/logger: merge file and line labels into location="file:line"

This should improve the usability for `vm_log_messages_total` metric during practical queries
This commit is contained in:
Aliaksandr Valialkin 2019-12-02 14:03:44 +02:00
parent 70b8191fab
commit 42da569bcd

View file

@ -123,7 +123,8 @@ func logMessage(level, msg string, skipframes int) {
mu.Unlock()
// Increment vm_log_messages_total
counterName := fmt.Sprintf(`vm_log_messages_total{app_version=%q, level=%q, file=%q, line="%d"}`, buildinfo.Version, levelLowercase, file, line)
location := fmt.Sprintf("%s:%d", file, line)
counterName := fmt.Sprintf(`vm_log_messages_total{app_version=%q, level=%q, location=%q}`, buildinfo.Version, levelLowercase, location)
metrics.GetOrCreateCounter(counterName).Inc()
switch level {