diff --git a/packages/opentelemetry-basic-tracer/src/export/InMemorySpanExporter.ts b/packages/opentelemetry-basic-tracer/src/export/InMemorySpanExporter.ts index 92e8fc9eb89..5d64d2e9276 100644 --- a/packages/opentelemetry-basic-tracer/src/export/InMemorySpanExporter.ts +++ b/packages/opentelemetry-basic-tracer/src/export/InMemorySpanExporter.ts @@ -19,12 +19,12 @@ import { ReadableSpan } from './ReadableSpan'; import { ExportResult } from './ExportResult'; /** - * This class can be used for testing purposes. It saves the exported spans - * in a list in memory that can be retrieve using the `getFinishedSpans` + * This class can be used for testing purposes. It stores the exported spans + * in a list in memory that can be retrieve using the `getFinishedSpans()` * method. */ export class InMemorySpanExporter implements SpanExporter { - private _finishedSpan: ReadableSpan[] = []; + private _finishedSpans: ReadableSpan[] = []; private _stopped = false; export( @@ -32,20 +32,20 @@ export class InMemorySpanExporter implements SpanExporter { resultCallback: (result: ExportResult) => void ): void { if (this._stopped) return resultCallback(ExportResult.FailedNonRetryable); - this._finishedSpan.push(...spans); + this._finishedSpans.push(...spans); return resultCallback(ExportResult.Success); } shutdown(): void { this._stopped = true; - this._finishedSpan = []; + this._finishedSpans = []; } reset() { - this._finishedSpan = []; + this._finishedSpans = []; } getFinishedSpans(): ReadableSpan[] { - return this._finishedSpan; + return this._finishedSpans; } } diff --git a/packages/opentelemetry-basic-tracer/test/MultiSpanProcessor.test.ts b/packages/opentelemetry-basic-tracer/test/MultiSpanProcessor.test.ts index f18f9849114..04760052afe 100644 --- a/packages/opentelemetry-basic-tracer/test/MultiSpanProcessor.test.ts +++ b/packages/opentelemetry-basic-tracer/test/MultiSpanProcessor.test.ts @@ -22,19 +22,17 @@ import { NoopScopeManager } from '@opentelemetry/scope-base'; class TestProcessor implements SpanProcessor { spans: Span[] = []; onStart(span: Span): void {} - onEnd(span: Span): void { this.spans.push(span); } shutdown(): void { - this.spans = [] + this.spans = []; } } - describe('MultiSpanProcessor', () => { const tracer = new BasicTracer({ - scopeManager: new NoopScopeManager() + scopeManager: new NoopScopeManager(), }); const span = tracer.startSpan('one'); @@ -43,7 +41,7 @@ describe('MultiSpanProcessor', () => { multiSpanProcessor.onStart(span); multiSpanProcessor.onEnd(span); multiSpanProcessor.shutdown(); - }) + }); it('should handle one span processor', () => { const processor1 = new TestProcessor(); @@ -52,7 +50,7 @@ describe('MultiSpanProcessor', () => { assert.strictEqual(processor1.spans.length, 0); multiSpanProcessor.onEnd(span); assert.strictEqual(processor1.spans.length, 1); - }) + }); it('should handle two span processor', () => { const processor1 = new TestProcessor(); @@ -68,5 +66,5 @@ describe('MultiSpanProcessor', () => { multiSpanProcessor.shutdown(); assert.strictEqual(processor1.spans.length, 0); assert.strictEqual(processor1.spans.length, processor2.spans.length); - }) + }); }); diff --git a/packages/opentelemetry-basic-tracer/test/export/InMemorySpanExporter.test.ts b/packages/opentelemetry-basic-tracer/test/export/InMemorySpanExporter.test.ts index 02a2d743cb1..9cf916fc726 100644 --- a/packages/opentelemetry-basic-tracer/test/export/InMemorySpanExporter.test.ts +++ b/packages/opentelemetry-basic-tracer/test/export/InMemorySpanExporter.test.ts @@ -15,7 +15,12 @@ */ import * as assert from 'assert'; -import { InMemorySpanExporter, SimpleSpanProcessor, BasicTracer, ExportResult } from '../../src'; +import { + InMemorySpanExporter, + SimpleSpanProcessor, + BasicTracer, + ExportResult, +} from '../../src'; import { NoopScopeManager } from '@opentelemetry/scope-base'; describe('InMemorySpanExporter', () => { @@ -28,12 +33,12 @@ describe('InMemorySpanExporter', () => { afterEach(() => { // reset spans in memory. memoryExporter.reset(); - }) + }); it('should get finished spans', () => { const root = tracer.startSpan('root'); - const child = tracer.startSpan('child', {parent: root}); - const grandChild = tracer.startSpan('grand-child', {parent: child}); + const child = tracer.startSpan('child', { parent: root }); + const grandChild = tracer.startSpan('grand-child', { parent: child }); assert.strictEqual(memoryExporter.getFinishedSpans().length, 0); grandChild.end(); @@ -55,15 +60,15 @@ describe('InMemorySpanExporter', () => { it('should shutdown the exorter', () => { const root = tracer.startSpan('root'); - tracer.startSpan('child', {parent: root}).end(); + tracer.startSpan('child', { parent: root }).end(); root.end(); assert.strictEqual(memoryExporter.getFinishedSpans().length, 2); memoryExporter.shutdown(); assert.strictEqual(memoryExporter.getFinishedSpans().length, 0); - // after shutdown no new spans are accepted - tracer.startSpan('child1', {parent: root}).end(); - assert.strictEqual(memoryExporter.getFinishedSpans().length, 0); + // after shutdown no new spans are accepted + tracer.startSpan('child1', { parent: root }).end(); + assert.strictEqual(memoryExporter.getFinishedSpans().length, 0); }); it('should return the success result', () => { @@ -82,5 +87,4 @@ describe('InMemorySpanExporter', () => { assert.strictEqual(result, ExportResult.FailedNonRetryable); }); }); - });