diff --git a/NEWS.md b/NEWS.md index 087b9173..ff12e8c9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ 1.3.3 ------ * Set Last-Modified header to allow for 304 responses +* Add profiling support (needs useProfiler in env config file) 1.3.2 ------ diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 9c8c10f8..82979b06 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -63,6 +63,10 @@ var config = { port: 6082, ttl: 86400 } + // If useProfiler is true every response will be served with an + // X-Tiler-Profile header containing elapsed timing for various + // steps taken for producing the response. + ,useProfiler:true }; module.exports = config; diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 5ee29407..b547f49a 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -57,6 +57,10 @@ var config = { port: 6082, ttl: 86400 } + // If useProfiler is true every response will be served with an + // X-Tiler-Profile header containing elapsed timing for various + // steps taken for producing the response. + ,useProfiler:false }; module.exports = config; diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index 7fc660c5..a90153f6 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -57,6 +57,10 @@ var config = { port: 6082, ttl: 86400 } + // If useProfiler is true every response will be served with an + // X-Tiler-Profile header containing elapsed timing for various + // steps taken for producing the response. + ,useProfiler:true }; module.exports = config; diff --git a/config/environments/test.js.example b/config/environments/test.js.example index ff636581..9da8aeb7 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -59,6 +59,10 @@ var config = { port: null, ttl: 86400 } + // If useProfiler is true every response will be served with an + // X-Tiler-Profile header containing elapsed timing for various + // steps taken for producing the response. + ,useProfiler:false }; module.exports = config; diff --git a/lib/cartodb/redis_pool.js b/lib/cartodb/redis_pool.js index d2c40cc2..2ef86461 100644 --- a/lib/cartodb/redis_pool.js +++ b/lib/cartodb/redis_pool.js @@ -77,4 +77,4 @@ var RedisPool = function(opts){ return me; }; -module.exports = RedisPool; \ No newline at end of file +module.exports = RedisPool; diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index fb7b8422..9957bf8a 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -37,7 +37,8 @@ module.exports = function(){ varnish_host: global.environment.varnish.host, varnish_port: global.environment.varnish.port, cache_enabled: global.environment.cache_enabled, - log_format: global.environment.log_format + log_format: global.environment.log_format, + useProfiler: global.environment.useProfiler }; // Be nice and warn if configured mapnik version @@ -313,6 +314,7 @@ module.exports = function(){ LZMA.decompress( lzma, function(result) { + if (req.profiler) req.profiler.done('LZMA decompress'); try { delete req.query.lzma _.extend(req.query, JSON.parse(result)) @@ -357,11 +359,14 @@ module.exports = function(){ var that = this; + if (req.profiler) req.profiler.done('req2params.setup'); + Step( function getPrivacy(){ cartoData.authorize(req, this); }, function gatekeep(err, data){ + if (req.profiler) req.profiler.done('cartoData.authorize'); if(err) throw err; if(data === "0") throw new Error("Sorry, you are unauthorized (permission denied)"); return data; @@ -372,18 +377,21 @@ module.exports = function(){ cartoData.getDatabase(req, this); }, function getGeometryType(err, data){ + if (req.profiler) req.profiler.done('cartoData.getDatabase'); if (err) throw err; _.extend(req.params, {dbname:data}); cartoData.getGeometryType(req, this); }, function finishSetup(err, data){ + if (req.profiler) req.profiler.done('cartoData.getGeometryType'); if ( err ) { callback(err, req); return; } if (!_.isNull(data)) _.extend(req.params, {geom_type: data}); that.addCacheChannel(req, function(err) { + if (req.profiler) req.profiler.done('addCacheChannel'); callback(err, req); }); } diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 68e156f4..6c62c2b6 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "windshaft-cartodb", - "version": "1.3.1", + "version": "1.3.3", "dependencies": { "node-varnish": { "version": "0.1.1" @@ -9,10 +9,10 @@ "version": "1.3.3" }, "windshaft": { - "version": "0.12.9", + "version": "0.13.0", "dependencies": { "grainstore": { - "version": "0.13.5", + "version": "0.13.6", "dependencies": { "carto": { "version": "0.9.3-cdb3", @@ -72,47 +72,7 @@ "version": "0.3.4" }, "sqlite3": { - "version": "2.1.10", - "dependencies": { - "tar.gz": { - "version": "0.1.1", - "dependencies": { - "fstream": { - "version": "0.1.22", - "dependencies": { - "rimraf": { - "version": "2.2.0" - }, - "graceful-fs": { - "version": "1.2.2" - }, - "inherits": { - "version": "1.0.0" - } - } - }, - "tar": { - "version": "0.1.17", - "dependencies": { - "inherits": { - "version": "1.0.0" - }, - "block-stream": { - "version": "0.0.6" - } - } - }, - "commander": { - "version": "1.1.1", - "dependencies": { - "keypress": { - "version": "0.1.0" - } - } - } - } - } - } + "version": "2.1.13" }, "mime": { "version": "1.2.9" diff --git a/package.json b/package.json index 83bf1e2a..718b7228 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "node-varnish": "0.1.1", "underscore" : "~1.3.3", - "windshaft" : "~0.12.9", + "windshaft" : "~0.13.0", "step": "0.0.x", "generic-pool": "~2.0.3", "redis": "~0.8.3",