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.2.7 to 0.4.0

4

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

@@ -15,4 +15,4 @@ "main": "index.js",

"rest": "^1.3.2",
"zipkin": "^0.2.7"
"zipkin": "^0.4.0"
}
}

@@ -15,3 +15,3 @@ # zipkin-instrumentation-cujojs-rest

const nameOfRemoteService = 'youtube';
const client = rest.wrap(restInterceptor, {tracer, serviceName: nameOfRemoteService});
const client = rest.wrap(restInterceptor, {tracer, remoteServiceName: nameOfRemoteService});

@@ -18,0 +18,0 @@ // Your application code here

@@ -19,3 +19,3 @@ /* eslint-disable no-param-reassign */

function request(req, {serviceName, tracer}) {
function request(req, {tracer, serviceName = 'unknown', remoteServiceName}) {
tracer.scoped(() => {

@@ -41,2 +41,8 @@ tracer.setId(tracer.createChildId());

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
}));
}
});

@@ -43,0 +49,0 @@

@@ -24,3 +24,7 @@ const {Tracer, ExplicitContext} = require('zipkin');

tracer.scoped(() => {
const client = rest.wrap(restInterceptor, {tracer, serviceName: 'service-a'});
const client = rest.wrap(restInterceptor, {
tracer,
serviceName: 'caller',
remoteServiceName: 'callee'
});
const port = server.address().port;

@@ -41,3 +45,3 @@ const path = `http://127.0.0.1:${port}/abc`;

expect(annotations[0].annotation.annotationType).to.equal('ServiceName');
expect(annotations[0].annotation.serviceName).to.equal('service-a');
expect(annotations[0].annotation.serviceName).to.equal('caller');

@@ -53,8 +57,11 @@ expect(annotations[1].annotation.annotationType).to.equal('Rpc');

expect(annotations[4].annotation.annotationType).to.equal('BinaryAnnotation');
expect(annotations[4].annotation.key).to.equal('http.status_code');
expect(annotations[4].annotation.value).to.equal('202');
expect(annotations[4].annotation.annotationType).to.equal('ServerAddr');
expect(annotations[4].annotation.serviceName).to.equal('callee');
expect(annotations[5].annotation.annotationType).to.equal('ClientRecv');
expect(annotations[5].annotation.annotationType).to.equal('BinaryAnnotation');
expect(annotations[5].annotation.key).to.equal('http.status_code');
expect(annotations[5].annotation.value).to.equal('202');
expect(annotations[6].annotation.annotationType).to.equal('ClientRecv');
const traceIdOnServer = responseData.traceId;

@@ -61,0 +68,0 @@ expect(traceIdOnServer).to.equal(traceId);

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