Skip to content

Commit

Permalink
Merge pull request #29 from signalfx/proxy-support
Browse files Browse the repository at this point in the history
add proxy support to ingest client and fix doc
  • Loading branch information
kchengsf authored Feb 22, 2017
2 parents b15f0b2 + bad86c9 commit 91a9749
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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://<USER>:<PASSWORD>@<HOST>:<PORT>`

### Reporting data

Expand Down
12 changes: 8 additions & 4 deletions lib/client/ingest/signal_fx_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ var version = require('../../../package.json').version;
* ingestEndpoint:"string",
* timeout:"number",
* batchSize:"number",
* userAgents:"array"
* }
* userAgents:"array",
* proxy:"string" //http://<USER>:<PASSWORD>@<HOST>:<PORT>
* }
*/
function SignalFxClient(apiToken, options) {
var _this = this;
Expand All @@ -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 = [];
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 91a9749

Please sign in to comment.