zipkin-instrumentation-fetch
Advanced tools
Comparing version 0.14.1 to 0.14.2
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
module.exports = require('./wrapFetch'); |
@@ -1,21 +0,28 @@ | ||
const { | ||
Instrumentation | ||
} = require('zipkin'); | ||
'use strict'; | ||
function wrapFetch(fetch, { tracer, serviceName, remoteServiceName }) { | ||
const instrumentation = new Instrumentation.HttpClient({ tracer, serviceName, remoteServiceName }); | ||
return function zipkinfetch(url, opts = {}) { | ||
return new Promise((resolve, reject) => { | ||
tracer.scoped(() => { | ||
const method = opts.method || 'GET'; | ||
const zipkinOpts = instrumentation.recordRequest(opts, url, method); | ||
const traceId = tracer.id; | ||
var _require = require('zipkin'), | ||
Instrumentation = _require.Instrumentation; | ||
fetch(url, zipkinOpts).then(res => { | ||
tracer.scoped(() => { | ||
function wrapFetch(fetch, _ref) { | ||
var tracer = _ref.tracer, | ||
serviceName = _ref.serviceName, | ||
remoteServiceName = _ref.remoteServiceName; | ||
var instrumentation = new Instrumentation.HttpClient({ tracer: tracer, serviceName: serviceName, remoteServiceName: remoteServiceName }); | ||
return function zipkinfetch(url) { | ||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return new Promise(function (resolve, reject) { | ||
tracer.scoped(function () { | ||
var method = opts.method || 'GET'; | ||
var zipkinOpts = instrumentation.recordRequest(opts, url, method); | ||
var traceId = tracer.id; | ||
fetch(url, zipkinOpts).then(function (res) { | ||
tracer.scoped(function () { | ||
instrumentation.recordResponse(traceId, res.status); | ||
}); | ||
resolve(res); | ||
}).catch(err => { | ||
tracer.scoped(() => { | ||
}).catch(function (err) { | ||
tracer.scoped(function () { | ||
instrumentation.recordError(traceId, err); | ||
@@ -22,0 +29,0 @@ }); |
{ | ||
"name": "zipkin-instrumentation-fetch", | ||
"version": "0.14.1", | ||
"version": "0.14.2", | ||
"description": "Interceptor for HTTP clients using the 'fetch' API", | ||
@@ -19,4 +19,4 @@ "main": "lib/index.js", | ||
"node-fetch": "^1.5.3", | ||
"zipkin": "^0.14.1" | ||
"zipkin": "^0.14.2" | ||
} | ||
} |
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
9448
185