Huge News!Announcing our $40M Series B led by Abstract Ventures.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.1.9 to 0.2.0

10

package.json
{
"name": "zipkin-instrumentation-cujojs-rest",
"version": "0.1.9",
"version": "0.2.0",
"description": "Interceptor for instrumenting HTTP calls from the cujoJS rest library",

@@ -9,3 +9,3 @@ "main": "index.js",

},
"author": "Openzipkin <openzipkin.alt@gmail.com>",
"author": "OpenZipkin <openzipkin.alt@gmail.com>",
"license": "Apache-2.0",

@@ -15,7 +15,5 @@ "repository": "https://github.com/openzipkin/zipkin-js",

"express": "^4.13.4",
"rest": "^1.3.2"
},
"peerDependencies": {
"zipkin": "^0.1.9"
"rest": "^1.3.2",
"zipkin": "^0.2.0"
}
}

39

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

@@ -20,14 +19,6 @@ Annotation

function request(req, {serviceName}) {
function recordTraceData(name) {
const method = getRequestMethod(req);
trace.recordServiceName(name);
trace.recordRpc(method.toUpperCase());
trace.recordBinary('http.url', req.path);
trace.recordAnnotation(new Annotation.ClientSend());
}
trace.withContext(() => {
trace.setId(trace.nextId());
const traceId = trace.id();
function request(req, {serviceName, tracer}) {
tracer.scoped(() => {
tracer.setId(tracer.createChildId());
const traceId = tracer.id;
this.traceId = traceId;

@@ -45,9 +36,7 @@

if (trace.isActivelyTracing()) {
if (serviceName instanceof Function) {
serviceName(req, recordTraceData);
} else {
recordTraceData(serviceName);
}
}
const method = getRequestMethod(req);
tracer.recordServiceName(serviceName);
tracer.recordRpc(method.toUpperCase());
tracer.recordBinary('http.url', req.path);
tracer.recordAnnotation(new Annotation.ClientSend());
});

@@ -58,7 +47,7 @@

function response(res) {
trace.withContext(() => {
trace.setId(this.traceId);
trace.recordBinary('http.status_code', res.status.code.toString());
trace.recordAnnotation(new Annotation.ClientRecv());
function response(res, {tracer}) {
tracer.scoped(() => {
tracer.setId(this.traceId);
tracer.recordBinary('http.status_code', res.status.code.toString());
tracer.recordAnnotation(new Annotation.ClientRecv());
});

@@ -65,0 +54,0 @@ return res;

@@ -1,2 +0,2 @@

const {trace} = require('zipkin');
const {Tracer, ExplicitContext} = require('zipkin');
const express = require('express');

@@ -19,6 +19,8 @@ const sinon = require('sinon');

const record = sinon.spy();
const tracer = {record};
const recorder = {record};
const ctxImpl = new ExplicitContext();
const tracer = new Tracer({recorder, ctxImpl});
trace.letTracer(tracer, () => {
const client = rest.wrap(restInterceptor, {serviceName: 'service-a'});
tracer.scoped(() => {
const client = rest.wrap(restInterceptor, {tracer, serviceName: 'service-a'});
const port = server.address().port;

@@ -25,0 +27,0 @@ const path = `http://127.0.0.1:${port}/abc`;

Sorry, the diff of this file is not supported yet

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