Skip to content

Commit d26f269

Browse files
committed
test: updated the spanbuffer test
1 parent 5982eca commit d26f269

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

packages/core/src/tracing/spanBuffer.js

-4
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,3 @@ function processSpan(span) {
516516
}
517517
return transform(span);
518518
}
519-
// export the processSpan function for use in test.
520-
if (process.env.NODE_ENV === 'test') {
521-
module.exports.processSpan = processSpan;
522-
}

packages/core/test/tracing/spanBuffer_test.js

+18-7
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ describe('tracing/spanBuffer', () => {
566566
verifyNoBatching(span1, span2);
567567
});
568568
});
569-
describe('processSpan fn', () => {
569+
describe('when ignoreEndpoints is enabled', () => {
570570
before(() => {
571571
spanBuffer.init(
572572
{
@@ -597,15 +597,26 @@ describe('tracing/spanBuffer', () => {
597597
}
598598
};
599599

600-
it('should filter out the span when command is listed in ignoreEndpoints config', () => {
601-
expect(spanBuffer.processSpan(span)).to.equal(null);
600+
it('should ignore the redis span when the operation is listed in the ignoreEndpoints config', () => {
601+
spanBuffer.addSpan(span);
602+
const spans = spanBuffer.getAndResetSpans();
603+
expect(spans).to.have.lengthOf(0);
602604
});
603605

604-
it('should transform and return the span for command not specified in ignoreEndpoints config', () => {
606+
it('should transform the redis span if the operation is not specified in the ignoreEndpoints config', () => {
605607
span.data.redis.operation = 'set';
606-
const result = spanBuffer.processSpan(span);
607-
expect(result.data.redis.command).to.equal('set');
608-
expect(result.data.redis).to.not.have.property('operation');
608+
spanBuffer.addSpan(span);
609+
const spans = spanBuffer.getAndResetSpans();
610+
expect(spans).to.have.lengthOf(1);
611+
expect(span.data.redis.command).to.equal('set');
612+
expect(span.data.redis).to.not.have.property('operation');
613+
});
614+
it('should return the span unmodified for unsupported ignore endpoints', () => {
615+
span.n = 'http';
616+
spanBuffer.addSpan(span);
617+
const spans = spanBuffer.getAndResetSpans();
618+
expect(spans).to.have.lengthOf(1);
619+
expect(span).to.deep.equal(span);
609620
});
610621
});
611622
});

0 commit comments

Comments
 (0)