New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zipkin-instrumentation-cujojs-rest

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zipkin-instrumentation-cujojs-rest - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

lib/index.js

10

package.json
{
"name": "zipkin-instrumentation-cujojs-rest",
"version": "0.5.1",
"version": "0.6.0",
"description": "Interceptor for instrumenting HTTP calls from the cujoJS rest library",
"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>",

"rest": "^1.3.2",
"zipkin": "^0.5.1"
"zipkin": "^0.6.0"
}
}

26

src/restInterceptor.js
/* eslint-disable no-param-reassign */
const interceptor = require('rest/interceptor');
const {
HttpHeaders: Header,
Annotation
} = require('zipkin');
Annotation,
Request
} = require('zipkin');

@@ -20,21 +20,12 @@ function getRequestMethod(req) {

function request(req, {tracer, serviceName = 'unknown', remoteServiceName}) {
tracer.scoped(() => {
return tracer.scoped(() => {
tracer.setId(tracer.createChildId());
const traceId = tracer.id;
this.traceId = traceId;
const reqWithHeaders = Request.addZipkinHeaders(req, traceId);
req.headers = req.headers || {};
req.headers[Header.TraceId] = traceId.traceId;
req.headers[Header.SpanId] = traceId.spanId;
traceId._parentId.ifPresent(psid => {
req.headers[Header.ParentSpanId] = psid;
});
traceId.sampled.ifPresent(sampled => {
req.headers[Header.Sampled] = sampled ? '1' : '0';
});
const method = getRequestMethod(req);
const method = getRequestMethod(reqWithHeaders);
tracer.recordServiceName(serviceName);
tracer.recordRpc(method.toUpperCase());
tracer.recordBinary('http.url', req.path);
tracer.recordBinary('http.url', reqWithHeaders.path);
tracer.recordAnnotation(new Annotation.ClientSend());

@@ -47,5 +38,4 @@ if (remoteServiceName) {

}
return reqWithHeaders;
});
return req;
}

@@ -52,0 +42,0 @@

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