Comparing version 0.1.3 to 0.2.0
45
index.js
@@ -1,18 +0,20 @@ | ||
var Dogstatsy = require('dogstatsy'); | ||
'use strict' | ||
module.exports = shim; | ||
const Dogstatsy = require('dogstatsy') | ||
module.exports = shim | ||
function shim (dockerode, opts) { | ||
var stats = new Dogstatsy(opts); | ||
var modem = dockerode.modem; | ||
modem._dial = modem.dial; | ||
modem.dial = dial; | ||
return dockerode; | ||
const stats = new Dogstatsy(opts) | ||
const modem = dockerode.modem | ||
modem._dial = modem.dial | ||
modem.dial = dial | ||
return dockerode | ||
function dial (options, callback) { | ||
var reportTiming = stats.histogram('node.dockerode.dial'); | ||
modem._dial(options, done); | ||
const reportTiming = stats.histogram('node.dockerode.dial') | ||
modem._dial(options, done) | ||
function done (err, payload) { | ||
reportTiming({ | ||
const tags = { | ||
path: filterPath(options.path), | ||
@@ -25,7 +27,9 @@ targetType: opts.targetType || 'unknown', | ||
dockerVersion: modem.version, | ||
success: err == null, | ||
success: err === null || err === undefined, | ||
statusCode: err && err.statusCode, | ||
errorCode: err && err.code | ||
}); | ||
callback(err, payload); | ||
} | ||
const allTags = Object.assign(opts.datadogTags || {}, tags) | ||
reportTiming(allTags) | ||
callback(err, payload) | ||
} | ||
@@ -35,3 +39,3 @@ } | ||
var dockerNouns = [ | ||
const dockerNouns = [ | ||
'attach', | ||
@@ -65,18 +69,19 @@ 'auth', | ||
'top', | ||
'update', | ||
'unpause', | ||
'version', | ||
'wait', | ||
'_ping', | ||
]; | ||
'_ping' | ||
] | ||
var isDockerNoun = new RegExp(dockerNouns.join('|')); | ||
const isDockerNoun = new RegExp(dockerNouns.join('|')) | ||
function filterPath (path) { | ||
return '/' + path | ||
.split('?')[0] //ignore query string | ||
.split('?')[0] // ignore query string | ||
.split('/') | ||
.filter(function (fragment) { | ||
return isDockerNoun.test(fragment); | ||
return isDockerNoun.test(fragment) | ||
}) | ||
.join('/'); | ||
.join('/') | ||
} |
{ | ||
"name": "dogerode", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "DogStatsD shim for dockerode", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "NODE_ENV=testing mocha -R spec" | ||
"lint": "standard --verbose", | ||
"test": "npm run lint && NODE_ENV=testing mocha -R spec" | ||
}, | ||
@@ -18,2 +19,12 @@ "repository": { | ||
], | ||
"standard": { | ||
"globals": [ | ||
"describe", | ||
"it", | ||
"before", | ||
"after", | ||
"beforeEach", | ||
"afterEach" | ||
] | ||
}, | ||
"author": "Runnable", | ||
@@ -30,5 +41,6 @@ "license": "ISC", | ||
"docker-mock": "0.0.4", | ||
"dockerode": "^1.2.10", | ||
"mocha": "^1.18.2" | ||
"dockerode": "2.3.1", | ||
"mocha": "^1.18.2", | ||
"standard": "8.1.0" | ||
} | ||
} |
@@ -1,8 +0,10 @@ | ||
var setCallback = require('dogstatsy/test/fixtures/DogStatsD'); | ||
var Docker = require('dockerode'); | ||
var docker = new Docker({ | ||
'use strict' | ||
const setCallback = require('dogstatsy/test/fixtures/DogStatsD') | ||
const Docker = require('dockerode') | ||
let docker = new Docker({ | ||
host: 'http://localhost', | ||
port: 4244 | ||
}); | ||
var dogerode = require('..'); | ||
}) | ||
const dogerode = require('..') | ||
@@ -12,21 +14,22 @@ docker = dogerode(docker, { | ||
port: 8126 | ||
}); | ||
}) | ||
var dockerMock = require('docker-mock'); | ||
dockerMock.listen(4244); | ||
const dockerMock = require('docker-mock') | ||
dockerMock.listen(4244) | ||
describe('dogerode', function () { | ||
it('should histogram', function (done) { | ||
var stat = 'node.dockerode.dial'; | ||
const stat = 'node.dockerode.dial' | ||
setCallback(stat, '|h', function (err, stat, val, tags) { | ||
if (stat !== stat || tags.path !== '/containers/json') { | ||
done(new Error('mismatch')); | ||
if (err) { | ||
return done(err) | ||
} | ||
if (stat && tags.path !== '/containers/json') { | ||
done(new Error('mismatch')) | ||
} else { | ||
done(); | ||
done() | ||
} | ||
}); | ||
docker.listContainers(function () {}); | ||
}); | ||
}); | ||
}) | ||
docker.listContainers(function () {}) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3778
106
4