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

zipkin-core

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zipkin-core - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

src/sampler.js

2

package.json
{
"name": "zipkin-core",
"version": "0.1.2",
"version": "0.1.3",
"description": "The core tracer for zipkin.js",

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

const {Some, verifyIsOptional} = require('./option');
class TraceId {
constructor({traceId, parentId, spanId, sampled}) {
constructor({traceId, parentId, spanId, sampled, flags = 0}) {
verifyIsOptional(traceId);

@@ -12,3 +12,3 @@ verifyIsOptional(parentId);

this._sampled = sampled;
this._flags = 0;
this._flags = flags;
}

@@ -15,0 +15,0 @@

@@ -9,5 +9,7 @@ const {now} = require('./time');

} = require('./internalRepresentations');
const {Sampler, alwaysSample} = require('./sampler');
function ZipkinTracer({
logger,
sampler = new Sampler(alwaysSample),
timeout = 60 * 1000000 // default timeout = 60 seconds

@@ -18,5 +20,8 @@ }) {

function writeSpan(id) {
logger.logSpan(partialSpans.get(id));
const spanToWrite = partialSpans.get(id);
// ready for garbage collection
partialSpans.delete(id);
if (sampler.shouldSample(spanToWrite)) {
logger.logSpan(spanToWrite);
}
}

@@ -23,0 +28,0 @@

@@ -12,5 +12,2 @@ const sinon = require('sinon');

trace.withContext(() => {
// let spanHasBeenLogged = false;
// let loggedSpan;
const logSpan = sinon.spy();

@@ -60,2 +57,31 @@

});
it('should respect the Sampler when filtering which spans to log', () => {
function runTest(sample) {
const sampler = {
shouldSample: () => sample
};
const logSpan = sinon.spy();
const tracer = new ZipkinTracer({
logger: {logSpan},
sampler
});
trace.withContext(() => {
trace.pushTracer(tracer);
trace.setId(new TraceId({
traceId: None,
parentId: new Some('a'),
spanId: 'c',
sampled: new Some(true)
}));
trace.recordAnnotation(new Annotation.ServerRecv());
trace.recordServiceName("test-service");
trace.recordAnnotation(new Annotation.ServerSend());
});
expect(logSpan.calledOnce).to.equal(sample);
}
runTest(true);
runTest(false);
});
});
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