zipkin-instrumentation-fetch
Advanced tools
Comparing version 0.16.0 to 0.16.1
@@ -15,6 +15,7 @@ "use strict"; | ||
}); | ||
return function zipkinfetch(url) { | ||
return function zipkinfetch(input) { | ||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return new Promise(function (resolve, reject) { | ||
tracer.scoped(function () { | ||
var url = typeof input === 'string' ? input : input.url; | ||
var method = opts.method || 'GET'; | ||
@@ -21,0 +22,0 @@ var zipkinOpts = instrumentation.recordRequest(opts, url, method); |
{ | ||
"name": "zipkin-instrumentation-fetch", | ||
"version": "0.16.0", | ||
"version": "0.16.1", | ||
"description": "Interceptor for HTTP clients using the 'fetch' API", | ||
@@ -20,5 +20,5 @@ "main": "lib/index.js", | ||
"node-fetch": "^1.5.3", | ||
"zipkin": "^0.16.0" | ||
"zipkin": "^0.16.1" | ||
}, | ||
"gitHead": "9e0eee22a07156056656c2eeca8b4f94d5dbed34" | ||
"gitHead": "9be8a88f4f3c33030cb327088453db34b87f9a60" | ||
} |
@@ -7,5 +7,6 @@ const { | ||
const instrumentation = new Instrumentation.HttpClient({tracer, serviceName, remoteServiceName}); | ||
return function zipkinfetch(url, opts = {}) { | ||
return function zipkinfetch(input, opts = {}) { | ||
return new Promise((resolve, reject) => { | ||
tracer.scoped(() => { | ||
const url = (typeof input === 'string') ? input : input.url; | ||
const method = opts.method || 'GET'; | ||
@@ -12,0 +13,0 @@ const zipkinOpts = |
@@ -87,3 +87,2 @@ const {Tracer, ExplicitContext, createNoopTracer} = require('zipkin'); | ||
it('should not throw when using fetch without options', function(done) { | ||
@@ -102,2 +101,16 @@ const tracer = createNoopTracer(); | ||
it('should not throw when using fetch with a request object', function(done) { | ||
const tracer = createNoopTracer(); | ||
const fetch = wrapFetch(nodeFetch, {serviceName: 'user-service', tracer}); | ||
const path = `http://127.0.0.1:${this.port}/user`; | ||
const request = {url: path}; | ||
fetch(request) | ||
.then(res => res.json()) | ||
.then(() => { | ||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
it('should record error', (done) => { | ||
@@ -104,0 +117,0 @@ const record = sinon.spy(); |
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
10132
203
6