Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zipkin

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zipkin - npm Package Compare versions

Comparing version 0.11.0 to 0.11.1

20

lib/tracer/index.js

@@ -143,9 +143,23 @@ 'use strict';

if (!traceId.sampled.getOrElse(false)) {
return result; // no need to stop as it was never started
}
// At this point we know we are sampled. Explicitly record against the ID
var explicitRecord = function explicitRecord(annotation) {
return _this.recorder.record(new Record({
traceId: traceId,
timestamp: now(_this._startTimestamp, _this._startTick),
annotation: annotation
}));
};
// Ensure the span representing the promise completes
return result.then(function (output) {
_this.recordAnnotation(new Annotation.LocalOperationStop());
explicitRecord(new Annotation.LocalOperationStop());
return output;
}).catch(function (err) {
_this.recordBinary('error', err.message ? err.message : err.toString());
_this.recordAnnotation(new Annotation.LocalOperationStop());
var message = err.message ? err.message : err.toString();
explicitRecord(new Annotation.BinaryAnnotation('error', message));
explicitRecord(new Annotation.LocalOperationStop());
throw err;

@@ -152,0 +166,0 @@ });

2

package.json
{
"name": "zipkin",
"version": "0.11.0",
"version": "0.11.1",
"description": "The core tracer for zipkin.js",

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

@@ -111,11 +111,23 @@ const {None, Some, fromNullable} = require('../option');

if (!traceId.sampled.getOrElse(false)) {
return result; // no need to stop as it was never started
}
// At this point we know we are sampled. Explicitly record against the ID
const explicitRecord = (annotation) => this.recorder.record(new Record({
traceId,
timestamp: now(this._startTimestamp, this._startTick),
annotation
}));
// Ensure the span representing the promise completes
return result
.then((output) => {
this.recordAnnotation(new Annotation.LocalOperationStop());
explicitRecord(new Annotation.LocalOperationStop());
return output;
})
.catch((err) => {
this.recordBinary('error', err.message ? err.message : err.toString());
this.recordAnnotation(new Annotation.LocalOperationStop());
const message = err.message ? err.message : err.toString();
explicitRecord(new Annotation.BinaryAnnotation('error', message));
explicitRecord(new Annotation.LocalOperationStop());
throw err;

@@ -122,0 +134,0 @@ });

@@ -118,5 +118,3 @@ const sinon = require('sinon');

Promise.delay(10)
.then(() => {
throw new Error('no smoothies. try our cake');
})
.then(() => 'smoothie')
);

@@ -137,9 +135,6 @@

return promise.catch((error) => {
expect(error).to.eql(new Error('no smoothies. try our cake'));
return promise.then((result) => {
expect(result).to.eql('smoothie');
expect(record.getCall(2).args[0].annotation).to.eql(
new Annotation.BinaryAnnotation('error', 'no smoothies. try our cake')
);
expect(record.getCall(3).args[0].annotation).to.eql(
new Annotation.LocalOperationStop()

@@ -151,2 +146,31 @@ );

it('should close the correct span for a promise', () => {
const record = sinon.spy();
const recorder = {record};
const ctxImpl = new ExplicitContext();
const localServiceName = 'smoothie-store';
const trace = new Tracer({ctxImpl, recorder, localServiceName});
ctxImpl.scoped(() => {
const promise = trace.local('buy-smoothie', () =>
Promise.delay(10)
.then(() => 'smoothie')
);
expect(isPromise(promise)).to.eql(true);
// hasn't finished yet, due to the delay
expect(record.getCall(2)).to.eql(null);
const expectedTraceId = record.getCall(1).args[0].traceId;
return promise.then((result) => {
expect(result).to.eql('smoothie');
expect(record.getCall(2).args[0].traceId).to.eql(
expectedTraceId
);
});
});
});
it('should make a local span for a promise that produces an error', () => {

@@ -153,0 +177,0 @@ const record = sinon.spy();

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