Skip to content

Commit

Permalink
ci: add TravisCI and fix ESLint errors
Browse files Browse the repository at this point in the history
Fixes: #7
PR-URL: #9
Reviewed-By: James Young <james.young@turner.com>
  • Loading branch information
jamsyoung committed Feb 23, 2016
1 parent 578a868 commit cef425e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"keyword-spacing": 2,
"linebreak-style": [2, "unix"],
"no-console": 0,
"no-trailing-spaces": 2,
"object-curly-spacing": [2, "never"],
"one-var": [2, "always"],
"prefer-template": 2,
Expand Down
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
node_js:
- "4.2"
- "4.3"
- "5.5"
- "5.6"
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ This package requires a few environment variable to be set.
- `REGION`

- `DEBUGMETRICS`



[![build](https://img.shields.io/travis/cnnlabs/cnn-metrics/master.svg?style=flat-square)](https://travis-ci.org/cnnlabs/cnn-metrics)
![node](https://img.shields.io/node/v/cnn-metrics.svg?style=flat-square)
[![npm](https://img.shields.io/npm/v/cnn-metrics.svg?style=flat-square)](https://www.npmjs.com/package/cnn-metrics)
[![npm-downloads](https://img.shields.io/npm/dm/cnn-metrics.svg?style=flat-square)](https://www.npmjs.com/package/cnn-metrics)
[![dependency-status](https://gemnasium.com/cnnlabs/cnn-metrics.svg)](https://gemnasium.com/cnnlabs/cnn-metrics)
10 changes: 5 additions & 5 deletions lib/graphite/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ Graphite.prototype.log = function (metrics) {
debug(`Flush has been called ${this.flushCounter}`);
this.flushCounter ++;
if (this.flushCounter % 10 === 0) { //show the message every 10 times
this.loggingMessageDisplayed = false;
this.loggingMessageDisplayed = false;
}

if (!this.loggingMessageDisplayed) {
debug('Logging to Graphite is disabled by default on non-production environments. To enable is set ENVIRONMENT to "production". Or set DEBUGMETRICS=1 to debug metric counters');
this.loggingMessageDisplayed = true;
};
}

// We don't want Graphite filling up with junk data from localhost
// so we disabled if logging isnt set up with valid data
// so we disabled if logging isnt set up with valid data
if (!this.isLogging ) {
return;
}
Expand Down
10 changes: 5 additions & 5 deletions lib/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Metrics = function (opts) {
this.httpRequest = new Plugins.HttpRequest();
this.httpResponse = new Plugins.HttpResponse();


this.system = new Plugins.System();
this.fetch = new Plugins.Fetch();
this.aggregators = [];
Expand All @@ -36,17 +35,18 @@ Metrics.prototype.init = function (opts) {
// Derive the keys based on the platform, Eg, <platform>.<application>.<instance>.<metric>
const platform = (process.env.DYNO) ? 'heroku' : 'localhost',
isProduction = (process.env.ENVIRONMENT === 'production' || process.env.NODE_ENV === 'production');


let self = this,
instance,
isLogging = (process.env.DEBUGMETRICS === '1');

isLogging = isLogging || isProduction;

if (!apiKey && (isLogging)) {
throw 'No HOSTEDGRAPHITE_APIKEY is set. Please set a false one if you are on your localhost.';
}

//Lets do something with Kub here...
if (platform === 'heroku') {
instance = process.env.DYNO.replace('.', '_');
Expand Down Expand Up @@ -177,7 +177,7 @@ Metrics.prototype.instrument = function (obj, opts) {
case 'http.request':
this.httpRequest.instrument(obj);
break;

default:
throw new Error('No valid "opts.as" argument given. You need to specify the object you want instrumented.');
}
Expand Down

0 comments on commit cef425e

Please sign in to comment.