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.6.1 to 0.7.0

2

lib/wrapFetch.js

@@ -44,3 +44,3 @@ 'use strict';

tracer.setId(traceId);
tracer.recordBinary('request.error', err.toString());
tracer.recordBinary('error', err.toString());
tracer.recordAnnotation(new Annotation.ClientRecv());

@@ -47,0 +47,0 @@ });

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

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -33,3 +33,3 @@ const {Annotation, Request} = require('zipkin');

tracer.setId(traceId);
tracer.recordBinary('request.error', err.toString());
tracer.recordBinary('error', err.toString());
tracer.recordAnnotation(new Annotation.ClientRecv());

@@ -36,0 +36,0 @@ });

@@ -98,2 +98,58 @@ const {Tracer, ExplicitContext, createNoopTracer} = require('zipkin');

});
it('should record error', (done) => {
const record = sinon.spy();
const recorder = {record};
const ctxImpl = new ExplicitContext();
const tracer = new Tracer({recorder, ctxImpl});
const fetch = wrapFetch(nodeFetch, {
tracer,
serviceName: 'caller',
remoteServiceName: 'callee'
});
ctxImpl.scoped(() => {
const id = tracer.createChildId();
tracer.setId(id);
const path = 'http://domain.invalid';
fetch(path, {method: 'post'})
.then(() => expect.fail())
.catch(() => {
const annotations = record.args.map(args => args[0]);
// All annotations should have the same trace id and span id
const traceId = annotations[0].traceId.traceId;
const spanId = annotations[0].traceId.spanId;
annotations.forEach(ann => expect(ann.traceId.traceId).to.equal(traceId));
annotations.forEach(ann => expect(ann.traceId.spanId).to.equal(spanId));
expect(annotations[0].annotation.annotationType).to.equal('ServiceName');
expect(annotations[0].annotation.serviceName).to.equal('caller');
expect(annotations[1].annotation.annotationType).to.equal('Rpc');
expect(annotations[1].annotation.name).to.equal('POST');
expect(annotations[2].annotation.annotationType).to.equal('BinaryAnnotation');
expect(annotations[2].annotation.key).to.equal('http.url');
expect(annotations[2].annotation.value).to.equal(path);
expect(annotations[3].annotation.annotationType).to.equal('ClientSend');
expect(annotations[4].annotation.annotationType).to.equal('ServerAddr');
expect(annotations[4].annotation.serviceName).to.equal('callee');
expect(annotations[5].annotation.annotationType).to.equal('BinaryAnnotation');
expect(annotations[5].annotation.key).to.equal('error');
expect(annotations[5].annotation.value)
.to.contain('getaddrinfo ENOTFOUND domain.invalid');
expect(annotations[6].annotation.annotationType).to.equal('ClientRecv');
expect(annotations[7]).to.be.undefined; // eslint-disable-line no-unused-expressions
done();
});
});
});
});
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