From 0a767848b35fcfd9e5daf0ad447420106ad478c0 Mon Sep 17 00:00:00 2001 From: Bryan Mikaelian Date: Fri, 3 Feb 2017 09:31:47 -0600 Subject: [PATCH] Feedback --- lib/librato.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/librato.js b/lib/librato.js index 3d50fcf..6db792b 100644 --- a/lib/librato.js +++ b/lib/librato.js @@ -24,7 +24,7 @@ url_parse = require('url').parse, var tunnelAgent = null; var debug, logAll; -var api, email, token, period, hostName, sourceRegex, includeMetrics, excludeMetrics; +var api, email, token, period, sourceName, hostName, sourceRegex, includeMetrics, excludeMetrics; // How long to wait before retrying a failed post, in seconds var retryDelaySecs = 5; @@ -304,6 +304,11 @@ var flush_stats = function librato_flush(ts, metrics) measure.tags.source = measure.source; } else { measure.name = sanitize_name(measureName); + + // Use the global config sourceName as a source tag, if it exists. + if (sourceName !== null) { + measure.tags.source = sourceName; + } } if (brokenMetrics[measure.name]) { @@ -540,7 +545,8 @@ exports.init = function librato_init(startup_time, config, events, logger) api = config.librato.api; email = config.librato.email; token = config.librato.token; - hostName = config.librato.source; + sourceName = config.librato.source; + hostName = config.librato.host; sourceRegex = config.librato.sourceRegex; snapTime = config.librato.snapTime; includeMetrics = config.librato.includeMetrics; @@ -629,8 +635,8 @@ exports.init = function librato_init(startup_time, config, events, logger) writeToLegacy = config.librato.writeToLegacy; } - // Set host as a global tag - tags['host'] = hostName; + // Set host as a global tag. Defaults to os.hostname() + tags.host = hostName; } if (!email || !token) {