From 65fccf8abe50fe6f986b75934be76ad6bef0cb82 Mon Sep 17 00:00:00 2001 From: Christopher Hoskin Date: Wed, 7 Nov 2018 16:08:31 +0000 Subject: [PATCH] Ensure gauge values are numeric, not string --- libraries/metrics/metrics.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/metrics/metrics.coffee b/libraries/metrics/metrics.coffee index d06cc3972c..63cfacf1ea 100644 --- a/libraries/metrics/metrics.coffee +++ b/libraries/metrics/metrics.coffee @@ -35,6 +35,9 @@ module.exports = Metrics = sanitizeKey: (key) -> key.replace /[^a-zA-Z0-9]/g, "_" + sanitizeValue: (value) -> + parseFloat(value) + set : (key, value, sampleRate = 1)-> statsd.set buildKey(key), value, sampleRate @@ -74,7 +77,7 @@ module.exports = Metrics = help: key, labelNames: ['name','host'] }) - gauges[key].set({name: name, host: hostname},value) + gauges[key].set({name: name, host: hostname},this.sanitizeValue(value)) globalGauge: (key, value, sampleRate = 1)-> statsd.gauge buildGlobalKey(key), value, sampleRate @@ -85,7 +88,7 @@ module.exports = Metrics = help: key, labelNames: ['name','host'] }) - gauges[key].set({name: name},value) + gauges[key].set({name: name},this.sanitizeValue(value)) mongodb: require "./mongodb" http: require "./http"