Skip to content

Commit 1e52c4e

Browse files
author
Michal Tichák
committed
fixup! [core] Added monitoring to hooks and communication with outside services
1 parent 1ecb0a3 commit 1e52c4e

File tree

2 files changed

+53
-45
lines changed

2 files changed

+53
-45
lines changed

common/monitoring/timer.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package monitoring
22

33
import (
44
"time"
5+
6+
"github.com/AliceO2Group/Control/common/logger/infologger"
57
)
68

79
type TimeResolution int
@@ -37,10 +39,13 @@ func timer(metric *Metric, unit TimeResolution, send bool, sendHistogrammable bo
3739
return func() {
3840
dur := time.Since(start)
3941
// we are setting default value as Nanoseconds
40-
if unit == Millisecond {
42+
switch unit {
43+
case Millisecond:
4144
metric.SetFieldInt64("execution_time_ms", dur.Milliseconds())
42-
} else {
45+
case Nanosecond:
4346
metric.SetFieldInt64("execution_time_ns", dur.Nanoseconds())
47+
default:
48+
log.WithField("level", infologger.IL_Devel).Warnf("trying to use unknown time resolution in monitoring.timer function [%d], skipping", unit)
4449
}
4550

4651
if send {

0 commit comments

Comments
 (0)