From cef425e2bc8f7b1a86ffa9182fda26b662e527e5 Mon Sep 17 00:00:00 2001 From: James Young Date: Tue, 23 Feb 2016 11:47:08 -0500 Subject: [PATCH] ci: add TravisCI and fix ESLint errors Fixes: #7 PR-URL: #9 Reviewed-By: James Young --- .eslintrc | 1 + .travis.yml | 6 ++++++ README.md | 8 ++++++++ lib/graphite/client.js | 10 +++++----- lib/metrics.js | 10 +++++----- 5 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 .travis.yml diff --git a/.eslintrc b/.eslintrc index d620b6c..2145ce4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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, diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..47735ac --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - "4.2" + - "4.3" + - "5.5" + - "5.6" diff --git a/README.md b/README.md index d60bd86..1996f0f 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lib/graphite/client.js b/lib/graphite/client.js index f13e619..67f0413 100644 --- a/lib/graphite/client.js +++ b/lib/graphite/client.js @@ -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; } diff --git a/lib/metrics.js b/lib/metrics.js index 5e1856c..37894bc 100644 --- a/lib/metrics.js +++ b/lib/metrics.js @@ -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 = []; @@ -36,17 +35,18 @@ Metrics.prototype.init = function (opts) { // Derive the keys based on the platform, Eg, ... 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('.', '_'); @@ -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.'); }