removed repeated code

This commit is contained in:
Henrique Chehad
2016-09-06 20:23:33 -03:00
parent 11d619b38e
commit 5697915676

View File

@@ -8,20 +8,20 @@ import (
"golang.org/x/net/context" "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 := titancommon.Logger(ctx)
log.WithFields(logrus.Fields{ 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) { func LogMetricCount(ctx context.Context, name string, value int) {
log := titancommon.Logger(ctx) LogMetric(ctx, name, "count", value)
log.WithFields(logrus.Fields{
"metric": name, "type": "count", "value": value}).Info()
} }
func LogMetricTime(ctx context.Context, name string, time time.Duration) { func LogMetricTime(ctx context.Context, name string, time time.Duration) {
log := titancommon.Logger(ctx) LogMetric(ctx, name, "time", time)
log.WithFields(logrus.Fields{
"metric": name, "type": "time", "value": time}).Info()
} }