From 4127913d283c0d7b96125e5d31802ba4be85e2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20St=C3=B6bich?= <18708370+Flarna@users.noreply.github.com> Date: Wed, 4 Mar 2020 14:10:57 +0100 Subject: [PATCH] chore: remove SpanOptions.isRecording (#817) Remove SpanOptions.isRecording as it seems to be quite useless and I found only Span.isRecording in spec. Also Java seems to have no such option for span creation. --- .../src/trace/SpanOptions.ts | 6 ---- .../noop-implementations/noop-tracer.test.ts | 1 - packages/opentelemetry-tracing/src/Tracer.ts | 3 +- .../test/BasicTracerProvider.test.ts | 36 ++----------------- 4 files changed, 3 insertions(+), 43 deletions(-) diff --git a/packages/opentelemetry-api/src/trace/SpanOptions.ts b/packages/opentelemetry-api/src/trace/SpanOptions.ts index 56d2d38428f..131d6d4f702 100644 --- a/packages/opentelemetry-api/src/trace/SpanOptions.ts +++ b/packages/opentelemetry-api/src/trace/SpanOptions.ts @@ -33,12 +33,6 @@ export interface SpanOptions { /** A spans attributes */ attributes?: Attributes; - /** - * Indicates that if this Span is active and recording information like - * events with the `AddEvent` operation and attributes using `setAttributes`. - */ - isRecording?: boolean; - /** A spans links */ links?: Link[]; diff --git a/packages/opentelemetry-api/test/noop-implementations/noop-tracer.test.ts b/packages/opentelemetry-api/test/noop-implementations/noop-tracer.test.ts index 8fd67c145df..fc623d2526a 100644 --- a/packages/opentelemetry-api/test/noop-implementations/noop-tracer.test.ts +++ b/packages/opentelemetry-api/test/noop-implementations/noop-tracer.test.ts @@ -30,7 +30,6 @@ describe('NoopTracer', () => { assert.deepStrictEqual( tracer.startSpan('span-name2', { kind: SpanKind.CLIENT, - isRecording: true, }), NOOP_SPAN ); diff --git a/packages/opentelemetry-tracing/src/Tracer.ts b/packages/opentelemetry-tracing/src/Tracer.ts index 088c4f16cb8..76553ee3606 100644 --- a/packages/opentelemetry-tracing/src/Tracer.ts +++ b/packages/opentelemetry-tracing/src/Tracer.ts @@ -83,8 +83,7 @@ export class Tracer implements api.Tracer { ? api.TraceFlags.SAMPLED : api.TraceFlags.UNSAMPLED; const spanContext = { traceId, spanId, traceFlags, traceState }; - const recordEvents = options.isRecording || false; - if (!recordEvents && !samplingDecision) { + if (!samplingDecision) { this.logger.debug('Sampling is off, starting no recording span'); return new NoRecordingSpan(spanContext); } diff --git a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts index 1ce6c12c63f..6d3a5836f46 100644 --- a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts @@ -281,43 +281,11 @@ describe('BasicTracerProvider', () => { span.end(); }); - it('should create real span when not sampled but recording events true', () => { - const tracer = new BasicTracerProvider({ - sampler: NEVER_SAMPLER, - }).getTracer('default'); - const span = tracer.startSpan('my-span', { isRecording: true }); - assert.ok(span instanceof Span); - assert.strictEqual(span.context().traceFlags, TraceFlags.UNSAMPLED); - assert.strictEqual(span.isRecording(), true); - }); - - it('should not create real span when not sampled and recording events false', () => { - const tracer = new BasicTracerProvider({ - sampler: NEVER_SAMPLER, - logger: new NoopLogger(), - }).getTracer('default'); - const span = tracer.startSpan('my-span', { isRecording: false }); - assert.ok(span instanceof NoRecordingSpan); - assert.strictEqual(span.context().traceFlags, TraceFlags.UNSAMPLED); - assert.strictEqual(span.isRecording(), false); - }); - - it('should not create real span when not sampled and no recording events configured', () => { - const tracer = new BasicTracerProvider({ - sampler: NEVER_SAMPLER, - logger: new NoopLogger(), - }).getTracer('default'); - const span = tracer.startSpan('my-span'); - assert.ok(span instanceof NoRecordingSpan); - assert.strictEqual(span.context().traceFlags, TraceFlags.UNSAMPLED); - assert.strictEqual(span.isRecording(), false); - }); - - it('should create real span when sampled and recording events true', () => { + it('should create real span when sampled', () => { const tracer = new BasicTracerProvider({ sampler: ALWAYS_SAMPLER, }).getTracer('default'); - const span = tracer.startSpan('my-span', { isRecording: true }); + const span = tracer.startSpan('my-span'); assert.ok(span instanceof Span); assert.strictEqual(span.context().traceFlags, TraceFlags.SAMPLED); assert.strictEqual(span.isRecording(), true);