Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zipkin-instrumentation-fetch

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zipkin-instrumentation-fetch - npm Package Compare versions

Comparing version 0.18.5 to 0.18.6

6

package.json
{
"name": "zipkin-instrumentation-fetch",
"version": "0.18.5",
"version": "0.18.6",
"description": "Interceptor for HTTP clients using the 'fetch' API",

@@ -17,3 +17,3 @@ "main": "lib/index.js",

"dependencies": {
"zipkin": "^0.18.5"
"zipkin": "^0.18.6"
},

@@ -23,3 +23,3 @@ "devDependencies": {

},
"gitHead": "201c6f6360d7ae79eaa04d5e53660908e3602358"
"gitHead": "98f7796d54199ccb2a81dea04c466a40814ccb24"
}
# zipkin-instrumentation-fetch
![npm](https://img.shields.io/npm/dm/zipkin-instrumentation-fetch.svg)
This library will wrap the [fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).

@@ -4,0 +6,0 @@ You need to provide your own `fetch` implementation; it could for example come from `window.fetch` (in the browser),

const {expect} = require('chai');
const {ExplicitContext, Tracer} = require('zipkin');
const {
maybeMiddleware,
expectB3Headers,
expectSpan,
inBrowser,
newSpanRecorder,
expectB3Headers,
expectSpan
setupTestServer
} = require('../../../test/testFixture');

@@ -17,21 +18,4 @@

let server;
let baseURL = ''; // default to relative path, for browser-based tests
const server = setupTestServer();
before((done) => {
const middleware = maybeMiddleware();
if (middleware !== null) {
server = middleware.listen(0, () => {
baseURL = `http://127.0.0.1:${server.address().port}`;
done();
});
} else { // Inside a browser
done();
}
});
after(() => {
if (server) server.close();
});
let spans;

@@ -56,6 +40,6 @@ let tracer;

let fetch;
if (server) { // defer loading node-fetch
if (inBrowser()) {
fetch = window.fetch; // eslint-disable-line
} else { // defer loading node-fetch
fetch = require('node-fetch'); // eslint-disable-line global-require
} else {
fetch = window.fetch; // eslint-disable-line
}

@@ -65,6 +49,2 @@ return wrapFetch(fetch, {tracer, remoteServiceName});

function url(path) {
return `${baseURL}${path}?index=10&count=300`;
}
function successSpan(path) {

@@ -86,3 +66,3 @@ return ({

// doesn't make assumptions about a span in progress: there won't be if there was a config error
wrappedFetch()(url)
wrappedFetch()(server.url)
.then((response) => {

@@ -104,3 +84,3 @@ done(new Error(`expected an invalid url parameter to error. status: ${response.status}`));

const path = '/weather/wuhan';
return wrappedFetch()(url(path))
return wrappedFetch()(server.url(path))
.then(response => response.json()) // json() returns a promise

@@ -113,3 +93,3 @@ .then(json => expectB3Headers(popSpan(), json));

const path = '/weather/wuhan';
return wrappedFetch()(url(path))
return wrappedFetch()(server.url(path))
.then(() => expectSpan(popSpan(), successSpan(path)));

@@ -120,3 +100,3 @@ });

const path = '/weather/wuhan';
return wrappedFetch()({url: url(path), method: 'GET'})
return wrappedFetch()({url: server.url(path), method: 'GET'})
.then(() => expectSpan(popSpan(), successSpan(path)));

@@ -127,3 +107,3 @@ });

const path = '/pathno';
return wrappedFetch()(url(path))
return wrappedFetch()(server.url(path))
.then(() => expectSpan(popSpan(), {

@@ -144,3 +124,3 @@ name: 'get',

const path = '/weather/securedTown';
return wrappedFetch()(url(path))
return wrappedFetch()(server.url(path))
.then(() => expectSpan(popSpan(), {

@@ -161,3 +141,3 @@ name: 'get',

const path = '/weather/bagCity';
return wrappedFetch()(url(path))
return wrappedFetch()(server.url(path))
.then(() => expectSpan(popSpan(), {

@@ -204,4 +184,4 @@ name: 'get',

const getBeijingWeather = client(url(beijing));
const getWuhanWeather = client(url(wuhan));
const getBeijingWeather = client(server.url(beijing));
const getWuhanWeather = client(server.url(wuhan));

@@ -223,4 +203,4 @@ return getBeijingWeather.then(() => {

const getBeijingWeather = client(url(beijing));
const getWuhanWeather = client(url(wuhan));
const getBeijingWeather = client(server.url(beijing));
const getWuhanWeather = client(server.url(wuhan));

@@ -227,0 +207,0 @@ return Promise.all([getBeijingWeather, getWuhanWeather]).then(() => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc