Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix log errors #11

Merged
merged 2 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = function (grunt) {
lines: 93,
statements:93,
branches: 83,
functions: 93
functions: 89
},
root: './lib',
reportFormats: ['lcov']
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ The custom options that can be set on config param are detailed below.
- staful.put('myCustomMetric', 200, {timestamp: '1471519331'});

// Aggregated Metrics
- staful.aggregatedCounter('myCounter', 1, 'avg', 60, {agg: ['sum']});
- staful.aggregatedCounter('myCounter', 1, 'avg', 60, { tags: { host: 'localhost' } });
- staful.aggregatedGauge('myGauge', 10, 'avg', 60, { tags: { host: 'localhost' } });
- staful.aggregatedTimer('myCounter', 200, 'avg', 60, {namespace: 'sandbox'});
- staful.aggregatedPut('myCustomMetric', 200, 'avg', 60, {timestamp: '1471519331'});
Expand Down
18 changes: 15 additions & 3 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ function performRequest(options, logger) {

req.on('error', function(e) {
if (e.code === "ECONNRESET") {
logger.error('A timeout occurred on a request to host: ' + options.hostname +
' port: ' + options.port + ' and path: ' + options.path);
if (logger) {
logger.error('A timeout occurred on a request to host: ' + options.hostname +
' port: ' + options.port + ' and path: ' + options.path);
}
} else {
logger.error('An error occurred: ' + e.message);
if (logger) {
logger.error('An error occurred: ' + e.message);
}
}
});

Expand Down Expand Up @@ -535,6 +539,10 @@ Client.prototype.aggregatedPut = function (name, value, agg, aggFreq, parameters
putAggregatedMetric(this, null, name, value, agg, aggFreq, parameters);
};

Client.prototype.aggregatedPutRaw = function (metricLine, agg, aggFreq) {
addToBuffer(this, [metricLine], true, agg, aggFreq);
};

/**
* Sends an aggregated timing metric
*
Expand Down Expand Up @@ -608,6 +616,10 @@ Client.prototype.put = function (name, value, parameters) {
putNonAggregatedMetric(this, null, name, value, parameters);
};

Client.prototype.putRaw = function (metricLine) {
addToBuffer(this, [metricLine], false, null, null);
};

/**
* Sends a timing metric
*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "git",
"url": "https://github.com/statful/statful-client-nodejs.git"
},
"version": "4.1.4",
"version": "4.1.5",
"engines": {
"node": ">=0.8"
},
Expand Down
6 changes: 3 additions & 3 deletions spec/common.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var Client = require('../lib/client');

var udpServer = require('./tools/udp-server');
var httpsServer = require('./tools/https-server');
var logger = require('bunyan').createLogger({name: 'tests'});
var logger = require('bunyan').createLogger({name: 'tests', level: 50});

var expect = require('chai').expect;
var sinon = require('sinon');
Expand All @@ -17,8 +17,8 @@ describe('When sending metrics', function () {
var apiConf;

beforeEach(function(){
httpPort = Math.floor(Math.random() * 20000) + 10001;
udpPort = Math.floor(Math.random() * 10000) + 1000;
httpPort = Math.floor(Math.random() * 10000) + 11025;
udpPort = Math.floor(Math.random() * 10000) + 1024;
apiConf = {
host: '127.0.0.1',
port: httpPort,
Expand Down
4 changes: 2 additions & 2 deletions spec/counter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ var logger = require('bunyan').createLogger({name: 'tests'});
var expect = require('chai').expect;

describe('When sending counter metrics', function () {
var httpPort = Math.floor(Math.random() * 20000) + 10001;
var udpPort = Math.floor(Math.random() * 10000) + 1000;
var httpPort = Math.floor(Math.random() * 10000) + 11025;
var udpPort = Math.floor(Math.random() * 10000) + 1024;
var apiConf = {
host: '127.0.0.1',
port: httpPort,
Expand Down
4 changes: 2 additions & 2 deletions spec/gauge.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ var logger = require('bunyan').createLogger({name: 'tests'});
var expect = require('chai').expect;

describe('When sending gauge metrics', function () {
var httpPort = Math.floor(Math.random() * 20000) + 10001;
var udpPort = Math.floor(Math.random() * 10000) + 1000;
var httpPort = Math.floor(Math.random() * 10000) + 11025;
var udpPort = Math.floor(Math.random() * 10000) + 1024;
var apiConf = {
host: '127.0.0.1',
port: httpPort,
Expand Down
4 changes: 2 additions & 2 deletions spec/timer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ var logger = require('bunyan').createLogger({name: 'tests'});
var expect = require('chai').expect;

describe('When sending timer metrics', function () {
var httpPort = Math.floor(Math.random() * 20000) + 10001;
var udpPort = Math.floor(Math.random() * 10000) + 1000;
var httpPort = Math.floor(Math.random() * 10000) + 11025;
var udpPort = Math.floor(Math.random() * 10000) + 1024;
var apiConf = {
host: '127.0.0.1',
port: httpPort,
Expand Down