From 56979156768211aab376dfb703e4efc2db2ef19c Mon Sep 17 00:00:00 2001 From: Henrique Chehad Date: Tue, 6 Sep 2016 20:23:33 -0300 Subject: [PATCH] removed repeated code --- api/runner/metrics.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api/runner/metrics.go b/api/runner/metrics.go index 2692850c1..2d34a65bb 100644 --- a/api/runner/metrics.go +++ b/api/runner/metrics.go @@ -8,20 +8,20 @@ import ( "golang.org/x/net/context" ) -func LogMetricGauge(ctx context.Context, name string, value int) { +func LogMetric(ctx context.Context, name string, metricType string, value interface{}) { log := titancommon.Logger(ctx) log.WithFields(logrus.Fields{ - "metric": name, "type": "gauge", "value": value}).Info() + "metric": name, "type": metricType, "value": value}).Info() +} + +func LogMetricGauge(ctx context.Context, name string, value int) { + LogMetric(ctx, name, "gauge", value) } func LogMetricCount(ctx context.Context, name string, value int) { - log := titancommon.Logger(ctx) - log.WithFields(logrus.Fields{ - "metric": name, "type": "count", "value": value}).Info() + LogMetric(ctx, name, "count", value) } func LogMetricTime(ctx context.Context, name string, time time.Duration) { - log := titancommon.Logger(ctx) - log.WithFields(logrus.Fields{ - "metric": name, "type": "time", "value": time}).Info() + LogMetric(ctx, name, "time", time) }