Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: signalfx/signalfx-nodejs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9c4f6e5d3f188399a2c44062e5831e367e857062
Choose a base ref
...
head repository: signalfx/signalfx-nodejs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d774b1db075c98b6baf549060ad4870ede0a9be0
Choose a head ref

Commits on Jun 16, 2016

  1. Merge pull request #6 from signalfx/updateDependencies

    update dependencies from dev to regular
    mpetazzoni authored Jun 16, 2016
    Copy the full SHA
    3bf063e View commit details

Commits on Jun 17, 2016

  1. update release version

    kchengsf committed Jun 17, 2016
    Copy the full SHA
    4aaec9d View commit details
  2. Merge pull request #7 from signalfx/updateDependencies

    update release version
    kchengsf authored Jun 17, 2016
    Copy the full SHA
    d0f255f View commit details

Commits on Aug 1, 2016

  1. Copy the full SHA
    9139d7c View commit details
  2. Merge pull request #8 from signalfx/v4

    update to v4, fixes a serious problem with multiple publishes
    unsetbit authored Aug 1, 2016
    Copy the full SHA
    1b69018 View commit details
  3. fix test

    kchengsf committed Aug 1, 2016
    Copy the full SHA
    705d505 View commit details
  4. fix lint errors

    kchengsf committed Aug 1, 2016
    Copy the full SHA
    b348731 View commit details

Commits on Oct 14, 2016

  1. allow sample parameter

    kchengsf committed Oct 14, 2016
    Copy the full SHA
    ee83deb View commit details
  2. Merge pull request #9 from signalfx/allowSample

    allow sample parameter
    bkarthiksf authored Oct 14, 2016
    Copy the full SHA
    cfba475 View commit details

Commits on Oct 15, 2016

  1. Copy the full SHA
    5e494eb View commit details

Commits on Oct 18, 2016

  1. no hasownproperty

    kchengsf committed Oct 18, 2016
    Copy the full SHA
    2606ea5 View commit details
  2. Merge pull request #10 from signalfx/allowSample

    pass through all parameters, and only force validation on mandatory f…
    9park authored Oct 18, 2016
    Copy the full SHA
    eba5ad5 View commit details
  3. Execute -> Start.

    9park committed Oct 18, 2016
    Copy the full SHA
    ff9671e View commit details
  4. Merge pull request #11 from signalfx/start

    Execute -> Start.
    kchengsf authored Oct 18, 2016
    Copy the full SHA
    e7d332b View commit details
  5. Change it back to 'execute'.

    9park committed Oct 18, 2016
    Copy the full SHA
    79a20b7 View commit details
  6. Merge pull request #12 from signalfx/execute

    Change it back to 'execute'.
    kchengsf authored Oct 18, 2016
    Copy the full SHA
    f4a62d7 View commit details

Commits on Oct 20, 2016

  1. Copy the full SHA
    34050e5 View commit details
  2. Merge pull request #13 from signalfx/dontRetryCompleted

    bump version and do not re-run computations for which the stream has …
    9park authored Oct 20, 2016
    Copy the full SHA
    3198d03 View commit details

Commits on Oct 25, 2016

  1. Copy the full SHA
    c18670f View commit details

Commits on Oct 27, 2016

  1. when datapoint sends were turned off, errors were being thrown for ba…

    …tchmessage composition
    kchengsf committed Oct 27, 2016
    Copy the full SHA
    004b48b View commit details
  2. Merge pull request #14 from signalfx/fixDataLessMessageFlush

    when datapoint sends were turned off, errors were being thrown for ba…
    kchengsf authored Oct 27, 2016
    Copy the full SHA
    999fd06 View commit details

Commits on Oct 31, 2016

  1. Copy the full SHA
    595b6e8 View commit details
  2. Merge pull request #15 from signalfx/fixMessageRoutingAndNoData

    fix messages routed to stopped jobs, and fix composition of empty data
    9park authored Oct 31, 2016
    Copy the full SHA
    b69d733 View commit details

Commits on Nov 1, 2016

  1. silently ignore stops on stopped computations, and dont try to assemb…

    …le batches when there is no data
    kchengsf committed Nov 1, 2016
    Copy the full SHA
    0476e18 View commit details
  2. Merge pull request #16 from signalfx/silentlyIgnoreBadStops

    silently ignore stops on stopped computations, and dont try to assemb…
    9park authored Nov 1, 2016
    Copy the full SHA
    743df45 View commit details

Commits on Nov 4, 2016

  1. Fix path to SignalFlow

    djmitche authored Nov 4, 2016
    Copy the full SHA
    b6a2809 View commit details
  2. fix typo

    djmitche authored Nov 4, 2016
    Copy the full SHA
    d4d848b View commit details

Commits on Nov 5, 2016

  1. Merge pull request #18 from djmitche/patch-2

    fix typo
    mpetazzoni authored Nov 5, 2016
    Copy the full SHA
    79db9d4 View commit details
  2. Merge pull request #17 from djmitche/patch-1

    Fix path to SignalFlow
    mpetazzoni authored Nov 5, 2016
    Copy the full SHA
    136ba8d View commit details

Commits on Nov 15, 2016

  1. Copy the full SHA
    1020f14 View commit details
  2. update broken test

    kchengsf committed Nov 15, 2016
    Copy the full SHA
    5226fc7 View commit details
  3. Merge pull request #20 from signalfx/silentlyIgnoreBadStops

    could stop before start, causing issues with handle assignment
    bkarthiksf authored Nov 15, 2016
    Copy the full SHA
    a8b4ca8 View commit details

Commits on Nov 30, 2016

  1. Copy the full SHA
    43f7ab6 View commit details
  2. version

    kchengsf committed Nov 30, 2016
    Copy the full SHA
    9ed19ff View commit details

Commits on Dec 1, 2016

  1. support 'explain' in signaflow js client

    in order to stream data and events for incidents by id
    bkarthiksf committed Dec 1, 2016
    Copy the full SHA
    4954db2 View commit details
  2. take care of lint errs

    bkarthiksf committed Dec 1, 2016
    Copy the full SHA
    328036e View commit details
  3. explain

    bkarthiksf committed Dec 1, 2016
    Copy the full SHA
    babc79c View commit details
  4. Merge pull request #21 from signalfx/reduceUnnecessaryGarbage

    Reduce unnecessary garbage
    kchengsf authored Dec 1, 2016
    Copy the full SHA
    2ad8c0f View commit details
  5. Merge pull request #22 from signalfx/explain-this

    support 'explain' in signaflow js client
    kchengsf authored Dec 1, 2016
    Copy the full SHA
    91db02f View commit details

Commits on Dec 8, 2016

  1. support routing of 'error' message types

    i think this might have been added recently. need this routing for
    error messages to make it to the client instead of being dropped
    bkarthiksf committed Dec 8, 2016
    Copy the full SHA
    d0c9add View commit details
  2. route error messages to an onError callback

    note that the signalflow client’s stream function args will not change,
    remains ‘stream(function(error, data) {…})’ as that’s node convention
    bkarthiksf committed Dec 8, 2016
    Copy the full SHA
    c4d3418 View commit details
  3. lint error fixes

    bkarthiksf committed Dec 8, 2016
    Copy the full SHA
    531bbad View commit details
  4. Merge pull request #24 from signalfx/add-support-for-error-message-type

    support routing of 'error' message types
    kchengsf authored Dec 8, 2016
    Copy the full SHA
    a0f0270 View commit details

Commits on Dec 14, 2016

  1. Copy the full SHA
    0a35975 View commit details
  2. fix lint

    kchengsf committed Dec 14, 2016
    Copy the full SHA
    6472938 View commit details

Commits on Dec 15, 2016

  1. upate version

    kchengsf committed Dec 15, 2016
    Copy the full SHA
    34638c9 View commit details
  2. Merge pull request #25 from signalfx/reconnectLogicAndBigNumber

    improve reconnect logic, and skip bigNumber when possible
    bkarthiksf authored Dec 15, 2016
    Copy the full SHA
    4f7d83c View commit details
  3. correct version...

    kchengsf committed Dec 15, 2016
    Copy the full SHA
    5ea368f View commit details

Commits on Jan 3, 2017

  1. Support data message wire format v2

    New wire format has a 2-byte version header and includes the batch's
    effective maxDelay.
    mpetazzoni committed Jan 3, 2017
    Copy the full SHA
    e36af73 View commit details
  2. 4.0.18

    mpetazzoni committed Jan 3, 2017
    Copy the full SHA
    a83b93f View commit details
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,3 +3,4 @@ coverage
build
.idea
*.iml
package-lock.json
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: node_js
node_js:
- "9.11"
- "8.11"
- "4.1"
- "4.0"
- '0.10'
- '0.12'
- 'iojs'
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -33,17 +33,18 @@ 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
+ **dimensions** - object, pre-defined dimensions for each datapoint and event. This object has key-value format `{ dimension_name: dimension_value, ...}`
+ **ingestEndpoint** - string, custom url to send datapoints in format http://custom.domain/api/path
+ **timeout** - number, sending datapoints timeout in ms (default is 1000ms)
+ **timeout** - number, sending datapoints timeout in ms (default is 5000ms)
+ **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

@@ -215,8 +216,9 @@ var handle = client.execute({
program: "data('cpu.utilization').mean().publish()",
start: Date.now() - 60000,
stop: Date.now() + 60000,
resolution: 10000});

resolution: 10000,
immediate: false});

handle.stream(function(err, data) { console.log(data); });
```

@@ -227,11 +229,12 @@ Please note that a token created via the REST API is necessary to use this API.
Parameters to the execute method are as follows :

+ **program** (string) - Required field. The signalflow to be run.
+ **start** (int | string) - A milliseconds since epoch number or a string representing a relative time : e.g. -1h. Defaults to now.
+ **end** (int | string) - A milliseconds since epoch number or a string representing a relative time : e.g. -30m. Defaults to infinity.
+ **resolution** (int) - The interval across which to calculate, in 1000 millisecond intervals. Defaults to 1000.
+ **start** (int | string) - A milliseconds since epoch number or a string representing a relative time : e.g. -1h. Defaults to now.
+ **stop** (int | string) - A milliseconds since epoch number or a string representing a relative time : e.g. -30m. Defaults to infinity.
+ **resolution** (int) - The interval across which to calculate, in 1000 millisecond intervals. Defaults to 1000.
+ **maxDelay** (int) - The maximum time to wait for a datapoint to arrive, in 10000 millisecond intervals. Defaults to dynamic.
+ **bigNumber** (boolean) - True if returned values require precision beyond MAX_SAFE_INTEGER. Returns all values in data messages as bignumber objects as per https://www.npmjs.com/package/bignumber.js Defaults to false.
+ **immediate** (boolean) - Whether to adjust the stop timestamp so that the computation doesn't wait for future data to be available.

#### Computation Objects

53 changes: 0 additions & 53 deletions circle.sh

This file was deleted.

19 changes: 0 additions & 19 deletions circle.yml

This file was deleted.

7 changes: 3 additions & 4 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@
}
</style>
</head>

<body>
<div class="graph"></div>
<script>
@@ -112,7 +111,7 @@

var token = 'YOUR USER TOKEN';

var sfxClient = signalfx.SignalFlow(token);
var sfxClient = signalfx.streamer.SignalFlow(token);

var j1 = sfxClient.execute({
program: "data('cpu.utilization').publish()",
@@ -122,13 +121,13 @@

j1.stream(function (err, data) {
if(!err) {
if ( data.type === signalfx.CONSTANTS.MESSAGE_TYPES.METADATA ) {
if ( data.type === signalfx.streamer.CONSTANTS.MESSAGE_TYPES.METADATA ) {
data.data = d3.range(limit).map(function() {
return 0;
});
groups[data.tsId] = data;
addGroup(data.tsId);
} else if ( data.type === signalfx.CONSTANTS.MESSAGE_TYPES.DATA) {
} else if ( data.type === signalfx.streamer.CONSTANTS.MESSAGE_TYPES.DATA) {
data.data.forEach(function (datapoint) {
groups[datapoint.tsId].data.push(datapoint.value);
groups[datapoint.tsId].path.attr('d', line);
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ gulp.task('test', ['pre-test'], function (cb) {

gulp.task('browserify', function () {
//todo : minify
return browserify('./lib/signalfx_browser.js', { standalone: 'signalfx' })
return browserify('./lib/signalfx_browser.js', { standalone: 'signalfx.streamer' })
.exclude('bufferutil')
.exclude('utf-8-validate')
//do NOT bundle websockets because the browser will provide it
5 changes: 4 additions & 1 deletion lib/client/conf.js
Original file line number Diff line number Diff line change
@@ -6,7 +6,10 @@ exports.DEFAULT_INGEST_ENDPOINT = 'https://ingest.signalfx.com';
exports.DEFAULT_API_ENDPOINT = 'https://api.signalfx.com';
exports.DEFAULT_SIGNALFLOW_WEBSOCKET_ENDPOINT = 'wss://stream.signalfx.com';
exports.DEFAULT_BATCH_SIZE = 300;// Will wait for this many requests before posting
exports.DEFAULT_TIMEOUT = 1000; // Default timeout is 1s
exports.DEFAULT_TIMEOUT = 5000; // Default timeout is 5s

// Whether to request SignalFlow WebSocket message compression.
exports.COMPRESS_SIGNALFLOW_WEBSOCKET_MESSAGES = true;

// Global Parameters
exports.PROTOBUF_HEADER_CONTENT_TYPE = 'application/x-protobuf';
8 changes: 4 additions & 4 deletions lib/client/ingest/protobuf_signal_fx_client.js
Original file line number Diff line number Diff line change
@@ -67,8 +67,8 @@ ProtoBufSignalFx.prototype._batchData = function (datapointsList) {
dpum.datapoints = dpum.datapoints.concat(datapointsList);

try {
var dataToSend = dpum.encode();
return dataToSend.toBuffer();
var dataToSend = protocolBuffers.DataPointUploadMessage.encode(dpum);
return dataToSend.finish();
} catch (error) {
winston.error('Invalid Protobuf object', error);
}
@@ -127,8 +127,8 @@ ProtoBufSignalFx.prototype._encodeEvent = function (protobufEvent) {
var eventMessage = new protocolBuffers.EventUploadMessage();
eventMessage.events = [];
eventMessage.events.push(protobufEvent);
var eventToSend = eventMessage.encode();
return eventToSend.toBuffer();
var eventToSend = protocolBuffers.EventUploadMessage.encode(eventMessage);
return eventToSend.finish();
};

exports.ProtoBufSignalFx = ProtoBufSignalFx;
47 changes: 26 additions & 21 deletions lib/client/ingest/signal_fx_client.js
Original file line number Diff line number Diff line change
@@ -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;
@@ -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 = [];
@@ -68,8 +70,6 @@ function SignalFxClient(apiToken, options) {
resolve();
});
});


}

SignalFxClient.prototype.AWSUniqueId_DIMENTION_NAME = 'AWSUniqueId';
@@ -103,7 +103,7 @@ SignalFxClient.prototype.send = function (data) {
return this.loadAWSUniqueId
.then(function () {
_this.processingData();
_this.startAsyncSend();
return _this.startAsyncSend();
});
};

@@ -156,7 +156,7 @@ SignalFxClient.prototype._batchData = function (datapointsList) {
* Send an event to SignalFx
*
* @param event - param object with following fields:
* category (int) - the category of event. Choose one from EVENT_CATEGORIES list
* category (string) - the category of event. Choose one from EVENT_CATEGORIES list
* eventType (string) - the event type (name of the event time series).
* dimensions (dict) - a map of event dimensions, empty dictionary by default
* properties (dict) - a map of extra properties on that event, empty dictionary by default
@@ -184,7 +184,7 @@ SignalFxClient.prototype.sendEvent = function (event) {

this.rawEvents.push(data);
return this.loadAWSUniqueId.then(function () {
_this.startAsyncEventSend();
return _this.startAsyncEventSend();
});
};

@@ -193,7 +193,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) {
@@ -240,9 +241,12 @@ SignalFxClient.prototype.startAsyncSend = function () {
var dataToSend = _this._batchData(datapointsList);
if (dataToSend && dataToSend.length > 0) {
var url = _this.ingestEndpoint + '/' + _this.INGEST_ENDPOINT_SUFFIX;
_this.post(dataToSend, url, _this.getHeaderContentType());
return _this.post(dataToSend, url, _this.getHeaderContentType());
}
}
return new Promise(function (resolve) {
resolve(null);
});
};

SignalFxClient.prototype.startAsyncEventSend = function () {
@@ -259,15 +263,15 @@ SignalFxClient.prototype.startAsyncEventSend = function () {
var eventToSend = _this._buildEvent(data);
if (eventToSend) {
var url = this.ingestEndpoint + '/' + this.EVENT_ENDPOINT_SUFFIX;
this.post(_this._encodeEvent(eventToSend), url, _this.getHeaderContentType());
return this.post(_this._encodeEvent(eventToSend), url, _this.getHeaderContentType());
}
} catch (error) {
winston.error('Can\'t processing event: ', error);
winston.error('Can\'t process event: ', error);
}
}
};

SignalFxClient.prototype.post = function (data, postUrl, contentType, callback) {
SignalFxClient.prototype.post = function (data, postUrl, contentType) {
var _this = this;

var headers = {};
@@ -285,17 +289,18 @@ 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) {
if (callback) {
callback();
}

if (error || response.statusCode !== 200) {
winston.error('Failed to sent datapoint: ', response ? response.statusCode : '', body, error);
}
return new Promise(function (resolve, reject) {
request(postOptions, function (error, response, body) {
if (error || response.statusCode !== 200) {
winston.error('Failed to send datapoint: ', response ? response.statusCode : '', body, error);
reject(error);
}
resolve(body);
});
});
};

Loading