Skip to content

Commit

Permalink
test: add missing calls to processor.onStart
Browse files Browse the repository at this point in the history
  • Loading branch information
quickgiant committed Aug 4, 2021
1 parent 0d41684 commit 645a887
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,14 @@ describe('BatchSpanProcessorBase', () => {

const span = createSampledSpan(`${name}_0`);

processor.onStart(span);
processor.onEnd(span);
assert.strictEqual(processor['_finishedSpans'].length, 1);

await processor.forceFlush();
assert.strictEqual(exporter.getFinishedSpans().length, 1);

processor.onStart(span);
processor.onEnd(span);
assert.strictEqual(processor['_finishedSpans'].length, 1);

Expand All @@ -145,6 +147,7 @@ describe('BatchSpanProcessorBase', () => {
assert.strictEqual(spy.args.length, 2);
assert.strictEqual(exporter.getFinishedSpans().length, 0);

processor.onStart(span);
processor.onEnd(span);
assert.strictEqual(spy.args.length, 2);
assert.strictEqual(processor['_finishedSpans'].length, 0);
Expand All @@ -157,6 +160,7 @@ describe('BatchSpanProcessorBase', () => {

const span = createUnsampledSpan(`${name}_0`);

processor.onStart(span);
processor.onEnd(span);

await processor.forceFlush();
Expand All @@ -177,6 +181,7 @@ describe('BatchSpanProcessorBase', () => {
assert.strictEqual(exporter.getFinishedSpans().length, 0);
}
const span = createSampledSpan(`${name}_6`);
processor.onStart(span);
processor.onEnd(span);

setTimeout(async () => {
Expand All @@ -194,6 +199,7 @@ describe('BatchSpanProcessorBase', () => {
const processor = new BatchSpanProcessor(exporter, defaultBufferConfig);
for (let i = 0; i < defaultBufferConfig.maxExportBatchSize; i++) {
const span = createSampledSpan(`${name}_${i}`);
processor.onStart(span);
processor.onEnd(span);
assert.strictEqual(exporter.getFinishedSpans().length, 0);
}
Expand All @@ -212,6 +218,7 @@ describe('BatchSpanProcessorBase', () => {
const processor = new BatchSpanProcessor(exporter, defaultBufferConfig);
for (let i = 0; i < defaultBufferConfig.maxExportBatchSize; i++) {
const span = createSampledSpan(`${name}_${i}`);
processor.onStart(span);
processor.onEnd(span);
}
assert.strictEqual(exporter.getFinishedSpans().length, 0);
Expand Down Expand Up @@ -259,9 +266,11 @@ describe('BatchSpanProcessorBase', () => {
const totalSpans = defaultBufferConfig.maxExportBatchSize * 2;
for (let i = 0; i < totalSpans; i++) {
const span = createSampledSpan(`${name}_${i}`);
processor.onStart(span);
processor.onEnd(span);
}
const span = createSampledSpan(`${name}_last`);
processor.onStart(span);
processor.onEnd(span);
clock.tick(defaultBufferConfig.scheduledDelayMillis + 10);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ describe('SimpleSpanProcessor', () => {
spanContext,
SpanKind.CLIENT
);
processor.onStart(span);

sinon.stub(exporter, 'export').callsFake((_, callback) => {
setTimeout(() => {
Expand Down Expand Up @@ -195,6 +196,7 @@ describe('SimpleSpanProcessor', () => {
SpanKind.CLIENT
);

processor.onStart(span);
processor.onEnd(span);

const exporterCreatedSpans = testTracingExporter.getExporterCreatedSpans();
Expand Down

0 comments on commit 645a887

Please sign in to comment.