diff --git a/lib/stackdriver.js b/lib/stackdriver.js index ee46e52..c919d98 100644 --- a/lib/stackdriver.js +++ b/lib/stackdriver.js @@ -92,15 +92,17 @@ StackdriverBackend.prototype.post_message_to_gateway = function(stackdriverMessa return; } + messageString = JSON.stringify(stackdriverMessage) + // setup the HTTPS request var options = { host : this.stackdriverHost, path : this.stackdriverPath, method : 'POST', headers : { + "Content-Length" : messageString.length, "Content-Type" : "application/json; charset=utf-8", "x-stackdriver-apikey" : this.apiKey, - "Content-Length" : stackdriverMessage.length, "User-Agent": "stackdriver-statsd-backend-0.1.2" } }; @@ -109,7 +111,7 @@ StackdriverBackend.prototype.post_message_to_gateway = function(stackdriverMessa if (this.debug) { util.log("Message contents to be posted:"); - util.log(JSON.stringify(stackdriverMessage)); + util.log(messageString); } // perform the HTTPS request @@ -128,7 +130,7 @@ StackdriverBackend.prototype.post_message_to_gateway = function(stackdriverMessa util.log("STACKDRIVER GATEWAY RESPONSE: " + chunk); }); }); - req.write(JSON.stringify(stackdriverMessage)); + req.write(messageString); req.end(); req.on('error', function(e) { diff --git a/package.json b/package.json index 5248919..bd5e6de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stackdriver-statsd-backend", - "version": "0.1.2", + "version": "0.1.3", "description": "Send metric data from statsd to Stackdriver", "main": "lib/stackdriver.js", "scripts": {