From b4fc8ec4a5f895f41b80c45b92c36b6ea6dedf78 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 19 Feb 2014 15:27:20 +0100 Subject: [PATCH] Allow using ":host" as part of statsd.prefix It'll be replaced with hostname. Closes #153 --- NEWS.md | 4 ++++ lib/cartodb/cartodb_windshaft.js | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 80f2d85b..b35e4018 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,10 @@ 1.8.2 -- 2014-MM-DD ------------------- +Enhancements: + + * Allow using ":host" as part of statsd.prefix (#153) + 1.8.1 -- 2014-02-19 ------------------- diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index 9a40725e..8f76ab71 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -7,11 +7,21 @@ var _ = require('underscore') , cartoData = require('cartodb-redis')(global.environment.redis) , SignedMaps = require('./signed_maps.js') , TemplateMaps = require('./template_maps.js') - , Cache = require('./cache_validator'); + , Cache = require('./cache_validator') + , os = require('os') +; var CartodbWindshaft = function(serverOptions) { var debug = global.environment.debug; + // Perform keyword substitution in statsd + // See https://github.com/CartoDB/Windshaft-cartodb/issues/153 + if ( global.environment.statsd ) { + if ( global.environment.statsd.prefix ) { + global.environment.statsd.prefix = global.environment.statsd.prefix.replace(/:host/, os.hostname()); + } + } + if(serverOptions.cache_enabled) { console.log("cache invalidation enabled, varnish on ", serverOptions.varnish_host, ' ', serverOptions.varnish_port); Cache.init(serverOptions.varnish_host, serverOptions.varnish_port, serverOptions.varnish_secret);