From 33dbde1ede0269f0d4e06bd3612335f1ff1f6918 Mon Sep 17 00:00:00 2001 From: "zyoshi (kamitsuk)" <35333687+paper2@users.noreply.github.com> Date: Tue, 5 Nov 2024 20:04:31 +0900 Subject: [PATCH] add reset function test for InMemorySpanExporter (#5107) Co-authored-by: Marc Pichler --- .../common/export/InMemorySpanExporter.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/opentelemetry-sdk-trace-base/test/common/export/InMemorySpanExporter.test.ts b/packages/opentelemetry-sdk-trace-base/test/common/export/InMemorySpanExporter.test.ts index 5bf4ddb8ff8..91c4bffaf63 100644 --- a/packages/opentelemetry-sdk-trace-base/test/common/export/InMemorySpanExporter.test.ts +++ b/packages/opentelemetry-sdk-trace-base/test/common/export/InMemorySpanExporter.test.ts @@ -93,6 +93,21 @@ describe('InMemorySpanExporter', () => { }); }); + it('should reset spans when reset is called', () => { + const root = provider.getTracer('default').startSpan('root'); + + provider + .getTracer('default') + .startSpan('child', {}, trace.setSpan(context.active(), root)) + .end(); + root.end(); + assert.strictEqual(memoryExporter.getFinishedSpans().length, 2); + + memoryExporter.reset(); + + assert.strictEqual(memoryExporter.getFinishedSpans().length, 0); + }); + it('should return the success result', () => { const exporter = new InMemorySpanExporter(); exporter.export([], (result: ExportResult) => {