Skip to content

Commit

Permalink
test: updated the spanbuffer test
Browse files Browse the repository at this point in the history
  • Loading branch information
aryamohanan committed Nov 29, 2024
1 parent 5982eca commit 536f492
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
4 changes: 0 additions & 4 deletions packages/core/src/tracing/spanBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,3 @@ function processSpan(span) {
}
return transform(span);
}
// export the processSpan function for use in test.
if (process.env.NODE_ENV === 'test') {
module.exports.processSpan = processSpan;
}
25 changes: 18 additions & 7 deletions packages/core/test/tracing/spanBuffer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ describe('tracing/spanBuffer', () => {
verifyNoBatching(span1, span2);
});
});
describe('processSpan fn', () => {
describe('when ignoreEndpoints is configured', () => {
before(() => {
spanBuffer.init(
{
Expand Down Expand Up @@ -597,15 +597,26 @@ describe('tracing/spanBuffer', () => {
}
};

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

it('should transform and return the span for command not specified in ignoreEndpoints config', () => {
it('should transform the redis span if the operation is not specified in the ignoreEndpoints config', () => {
span.data.redis.operation = 'set';
const result = spanBuffer.processSpan(span);
expect(result.data.redis.command).to.equal('set');
expect(result.data.redis).to.not.have.property('operation');
spanBuffer.addSpan(span);
const spans = spanBuffer.getAndResetSpans();
expect(spans).to.have.lengthOf(1);
expect(span.data.redis.command).to.equal('set');
expect(span.data.redis).to.not.have.property('operation');
});
it('should return the span unmodified for unsupported ignore endpoints', () => {
span.n = 'http';
spanBuffer.addSpan(span);
const spans = spanBuffer.getAndResetSpans();
expect(spans).to.have.lengthOf(1);
expect(span).to.deep.equal(span);
});
});
});
Expand Down

0 comments on commit 536f492

Please sign in to comment.