From bad86c940251a249cf303f2fff38500d4157fd19 Mon Sep 17 00:00:00 2001 From: Charlie Smith Date: Wed, 22 Feb 2017 15:05:54 -0500 Subject: [PATCH] add proxy support to ingest client and fix doc --- README.md | 5 +++-- lib/client/ingest/signal_fx_client.js | 12 ++++++++---- package.json | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ec6484f..7ddafca 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,9 @@ There are two ways to create an ingest client object: var signalfx = require('signalfx'); // Create default client -var client = new signalfx.Ingest('MY_SIGNALFX_TOKEN' [, options]); +var client = new signalfx.Ingest('MY_SIGNALFX_TOKEN', {options}); // or create JSON client -var clientJson = new signalfx.IngestJson('MY_SIGNALFX_TOKEN' [, options]); +var clientJson = new signalfx.IngestJson('MY_SIGNALFX_TOKEN', {options}); ``` Object `options` is an optional map and may contains following fields: + **enableAmazonUniqueId** - boolean, `false` by default. If `true`, library will retrieve Amazon unique identifier and set it as `AWSUniqueId` dimension for each datapoint and event. Use this option only if your application deployed to Amazon @@ -44,6 +44,7 @@ Object `options` is an optional map and may contains following fields: + **timeout** - number, sending datapoints timeout in ms (default is 1000ms) + **batchSize** - number, batch size to group sending datapoints + **userAgents** - array of strings, items from this array will be added to 'user-agent' header separated by comma ++ **proxy** - string, defines an address and credentials for sending metrics through a proxy server. The string should have the following format `http://:@:` ### Reporting data diff --git a/lib/client/ingest/signal_fx_client.js b/lib/client/ingest/signal_fx_client.js index 198ba23..c16ae1c 100644 --- a/lib/client/ingest/signal_fx_client.js +++ b/lib/client/ingest/signal_fx_client.js @@ -25,8 +25,9 @@ var version = require('../../../package.json').version; * ingestEndpoint:"string", * timeout:"number", * batchSize:"number", - * userAgents:"array" - * } + * userAgents:"array", + * proxy:"string" //http://:@: + * } */ function SignalFxClient(apiToken, options) { var _this = this; @@ -40,6 +41,7 @@ function SignalFxClient(apiToken, options) { this.userAgents = params.userAgents || null; this.globalDimensions = params.dimensions || {}; this.enableAmazonUniqueId = params.enableAmazonUniqueId || false; + this.proxy = params.proxy || null; this.rawData = []; this.rawEvents = []; @@ -193,7 +195,8 @@ SignalFxClient.prototype._retrieveAWSUniqueId = function (callback) { var getOptions = { url: conf.AWS_UNIQUE_ID_URL, timeout: 1000, - method: 'GET' + method: 'GET', + proxy: this.proxy }; request(getOptions, function (error, response, body) { @@ -285,7 +288,8 @@ SignalFxClient.prototype.post = function (data, postUrl, contentType, callback) timeout: _this.timeout, headers: headers, body: data, - method: 'POST' + method: 'POST', + proxy: _this.proxy }; request(postOptions, function (error, response, body) { diff --git a/package.json b/package.json index 3a8d6b5..bf414a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "signalfx", - "version": "4.0.20", + "version": "4.0.21", "description": "Node.js client library for SignalFx", "homepage": "https://signalfx.com", "repository": "https://github.com/signalfx/signalfx-nodejs",