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.9.0 to 0.10.0

test/.eslintrc

28

lib/wrapFetch.js
'use strict';
var _require = require('zipkin'),
Annotation = _require.Annotation,
Request = _require.Request;
Instrumentation = _require.Instrumentation;

@@ -13,2 +12,3 @@ function wrapFetch(fetch, _ref) {

var instrumentation = new Instrumentation.HttpClient({ tracer: tracer, serviceName: serviceName, remoteServiceName: remoteServiceName });
return function zipkinfetch(url) {

@@ -19,23 +19,9 @@ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

tracer.scoped(function () {
tracer.setId(tracer.createChildId());
var method = opts.method || 'GET';
var zipkinOpts = instrumentation.recordRequest(opts, url, method);
var traceId = tracer.id;
var method = opts.method || 'GET';
tracer.recordServiceName(serviceName);
tracer.recordRpc(method.toUpperCase());
tracer.recordBinary('http.url', url);
tracer.recordAnnotation(new Annotation.ClientSend());
if (remoteServiceName) {
// TODO: can we get the host and port of the http connection?
tracer.recordAnnotation(new Annotation.ServerAddr({
serviceName: remoteServiceName
}));
}
var zipkinOpts = Request.addZipkinHeaders(opts, traceId);
fetch(url, zipkinOpts).then(function (res) {
tracer.scoped(function () {
tracer.setId(traceId);
tracer.recordBinary('http.status_code', res.status.toString());
tracer.recordAnnotation(new Annotation.ClientRecv());
instrumentation.recordResponse(traceId, res.status);
});

@@ -45,5 +31,3 @@ resolve(res);

tracer.scoped(function () {
tracer.setId(traceId);
tracer.recordBinary('error', err.toString());
tracer.recordAnnotation(new Annotation.ClientRecv());
instrumentation.recordError(traceId, err);
});

@@ -50,0 +34,0 @@ reject(err);

{
"name": "zipkin-instrumentation-fetch",
"version": "0.9.0",
"version": "0.10.0",
"description": "Interceptor for HTTP clients using the 'fetch' API",

@@ -19,4 +19,4 @@ "main": "lib/index.js",

"node-fetch": "^1.5.3",
"zipkin": "^0.9.0"
"zipkin": "^0.10.0"
}
}

@@ -1,28 +0,18 @@

const {Annotation, Request} = require('zipkin');
const {
Instrumentation
} = require('zipkin');
function wrapFetch(fetch, {tracer, serviceName = 'unknown', remoteServiceName}) {
const instrumentation = new Instrumentation.HttpClient({tracer, serviceName, remoteServiceName});
return function zipkinfetch(url, opts = {}) {
return new Promise((resolve, reject) => {
tracer.scoped(() => {
tracer.setId(tracer.createChildId());
const method = opts.method || 'GET';
const zipkinOpts =
instrumentation.recordRequest(opts, url, method);
const traceId = tracer.id;
const method = opts.method || 'GET';
tracer.recordServiceName(serviceName);
tracer.recordRpc(method.toUpperCase());
tracer.recordBinary('http.url', url);
tracer.recordAnnotation(new Annotation.ClientSend());
if (remoteServiceName) {
// TODO: can we get the host and port of the http connection?
tracer.recordAnnotation(new Annotation.ServerAddr({
serviceName: remoteServiceName
}));
}
const zipkinOpts = Request.addZipkinHeaders(opts, traceId);
fetch(url, zipkinOpts).then(res => {
tracer.scoped(() => {
tracer.setId(traceId);
tracer.recordBinary('http.status_code', res.status.toString());
tracer.recordAnnotation(new Annotation.ClientRecv());
instrumentation.recordResponse(traceId, res.status);
});

@@ -32,5 +22,3 @@ resolve(res);

tracer.scoped(() => {
tracer.setId(traceId);
tracer.recordBinary('error', err.toString());
tracer.recordAnnotation(new Annotation.ClientRecv());
instrumentation.recordError(traceId, err);
});

@@ -37,0 +25,0 @@ reject(err);

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