zipkin-instrumentation-fetch
Advanced tools
Comparing version 0.5.1 to 0.6.0
{ | ||
"name": "zipkin-instrumentation-fetch", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"description": "Interceptor for HTTP clients using the 'fetch' API", | ||
"main": "index.js", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "node ../../node_modules/mocha/bin/mocha --require ../../test/helper.js" | ||
"build": "../../node_modules/.bin/babel src -d lib", | ||
"test": "node ../../node_modules/mocha/bin/mocha --require ../../test/helper.js", | ||
"prepublish": "npm run build" | ||
}, | ||
@@ -15,4 +17,4 @@ "author": "OpenZipkin <openzipkin.alt@gmail.com>", | ||
"node-fetch": "^1.5.1", | ||
"zipkin": "^0.5.1" | ||
"zipkin": "^0.6.0" | ||
} | ||
} |
@@ -11,3 +11,2 @@ # zipkin-instrumentation-fetch | ||
const {Tracer} = require('zipkin'); | ||
const rest = require('rest'); | ||
const wrapFetch = require('zipkin-instrumentation-fetch'); | ||
@@ -14,0 +13,0 @@ |
@@ -1,18 +0,3 @@ | ||
const {HttpHeaders, Annotation} = require('zipkin'); | ||
const {Annotation, Request} = require('zipkin'); | ||
function getHeaders(traceId, opts) { | ||
const headers = opts.headers || {}; | ||
headers[HttpHeaders.TraceId] = traceId.traceId; | ||
headers[HttpHeaders.SpanId] = traceId.spanId; | ||
traceId._parentId.ifPresent(psid => { | ||
headers[HttpHeaders.ParentSpanId] = psid; | ||
}); | ||
traceId.sampled.ifPresent(sampled => { | ||
headers[HttpHeaders.Sampled] = sampled ? '1' : '0'; | ||
}); | ||
return headers; | ||
} | ||
function wrapFetch(fetch, {tracer, serviceName = 'unknown', remoteServiceName}) { | ||
@@ -37,5 +22,3 @@ return function zipkinfetch(url, opts = {}) { | ||
const headers = getHeaders(traceId, opts); | ||
const zipkinOpts = Object.assign({}, opts, {headers}); | ||
const zipkinOpts = Request.addZipkinHeaders(opts, traceId); | ||
fetch(url, zipkinOpts).then(res => { | ||
@@ -42,0 +25,0 @@ tracer.scoped(() => { |
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
8011
8
157
21
4