From 66574df60f2c4e4849f903fbb5c58ead913c95b0 Mon Sep 17 00:00:00 2001 From: xiao-lix Date: Tue, 22 Oct 2019 14:39:42 -0700 Subject: [PATCH 1/3] fix(span): rename span recording flag --- packages/opentelemetry-core/src/trace/NoopSpan.ts | 4 ++-- .../opentelemetry-core/test/trace/NoopSpan.test.ts | 2 +- .../test/trace/NoopTracer.test.ts | 2 +- .../opentelemetry-node/test/NodeTracer.test.ts | 2 +- packages/opentelemetry-tracing/src/BasicTracer.ts | 2 +- packages/opentelemetry-tracing/src/Span.ts | 2 +- .../opentelemetry-tracing/src/SpanProcessor.ts | 4 ++-- .../opentelemetry-tracing/test/BasicTracer.test.ts | 14 +++++++------- packages/opentelemetry-tracing/test/Span.test.ts | 6 +++--- .../test/export/BatchSpanProcessor.test.ts | 2 +- .../opentelemetry-types/src/trace/SpanOptions.ts | 2 +- packages/opentelemetry-types/src/trace/span.ts | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/opentelemetry-core/src/trace/NoopSpan.ts b/packages/opentelemetry-core/src/trace/NoopSpan.ts index cd4b7e4658..84a5cf4241 100644 --- a/packages/opentelemetry-core/src/trace/NoopSpan.ts +++ b/packages/opentelemetry-core/src/trace/NoopSpan.ts @@ -66,8 +66,8 @@ export class NoopSpan implements types.Span { // By default does nothing end(endTime?: types.TimeInput): void {} - // isRecordingEvents always returns false for noopSpan. - isRecordingEvents(): boolean { + // isRecording always returns false for noopSpan. + isRecording(): boolean { return false; } } diff --git a/packages/opentelemetry-core/test/trace/NoopSpan.test.ts b/packages/opentelemetry-core/test/trace/NoopSpan.test.ts index dac450162b..468c42947d 100644 --- a/packages/opentelemetry-core/test/trace/NoopSpan.test.ts +++ b/packages/opentelemetry-core/test/trace/NoopSpan.test.ts @@ -51,7 +51,7 @@ describe('NoopSpan', () => { span.updateName('my-span'); - assert.ok(!span.isRecordingEvents()); + assert.ok(!span.isRecording()); assert.deepStrictEqual(span.context(), { traceId: INVALID_TRACEID, spanId: INVALID_SPANID, diff --git a/packages/opentelemetry-core/test/trace/NoopTracer.test.ts b/packages/opentelemetry-core/test/trace/NoopTracer.test.ts index cd93d5b548..892e082105 100644 --- a/packages/opentelemetry-core/test/trace/NoopTracer.test.ts +++ b/packages/opentelemetry-core/test/trace/NoopTracer.test.ts @@ -32,7 +32,7 @@ describe('NoopTracer', () => { assert.deepStrictEqual( tracer.startSpan('span-name2', { kind: SpanKind.CLIENT, - isRecordingEvents: true, + isRecording: true, }), NOOP_SPAN ); diff --git a/packages/opentelemetry-node/test/NodeTracer.test.ts b/packages/opentelemetry-node/test/NodeTracer.test.ts index 069d4980e2..0cffd80c0d 100644 --- a/packages/opentelemetry-node/test/NodeTracer.test.ts +++ b/packages/opentelemetry-node/test/NodeTracer.test.ts @@ -146,7 +146,7 @@ describe('NodeTracer', () => { const span = tracer.startSpan('my-span'); assert.ok(span instanceof NoRecordingSpan); assert.strictEqual(span.context().traceFlags, TraceFlags.UNSAMPLED); - assert.strictEqual(span.isRecordingEvents(), false); + assert.strictEqual(span.isRecording(), false); }); // @todo: implement diff --git a/packages/opentelemetry-tracing/src/BasicTracer.ts b/packages/opentelemetry-tracing/src/BasicTracer.ts index 5e6bff441b..a9936df1a8 100644 --- a/packages/opentelemetry-tracing/src/BasicTracer.ts +++ b/packages/opentelemetry-tracing/src/BasicTracer.ts @@ -88,7 +88,7 @@ export class BasicTracer implements types.Tracer { ? TraceFlags.SAMPLED : TraceFlags.UNSAMPLED; const spanContext = { traceId, spanId, traceFlags, traceState }; - const recordEvents = options.isRecordingEvents || false; + const recordEvents = options.isRecording || false; if (!recordEvents && !samplingDecision) { this.logger.debug('Sampling is off, starting no recording span'); return new NoRecordingSpan(spanContext); diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts index 618b860775..c59b96b460 100644 --- a/packages/opentelemetry-tracing/src/Span.ts +++ b/packages/opentelemetry-tracing/src/Span.ts @@ -148,7 +148,7 @@ export class Span implements types.Span, ReadableSpan { this._spanProcessor.onEnd(this); } - isRecordingEvents(): boolean { + isRecording(): boolean { return true; } diff --git a/packages/opentelemetry-tracing/src/SpanProcessor.ts b/packages/opentelemetry-tracing/src/SpanProcessor.ts index 633cfc1e56..74c3fb078e 100644 --- a/packages/opentelemetry-tracing/src/SpanProcessor.ts +++ b/packages/opentelemetry-tracing/src/SpanProcessor.ts @@ -22,14 +22,14 @@ import { Span } from '@opentelemetry/types'; */ export interface SpanProcessor { /** - * Called when a {@link Span} is started, if the `span.isRecordingEvents()` + * Called when a {@link Span} is started, if the `span.isRecording()` * returns true. * @param span the Span that just started. */ onStart(span: Span): void; /** - * Called when a {@link Span} is ended, if the `span.isRecordingEvents()` + * Called when a {@link Span} is ended, if the `span.isRecording()` * returns true. * @param span the Span that just ended. */ diff --git a/packages/opentelemetry-tracing/test/BasicTracer.test.ts b/packages/opentelemetry-tracing/test/BasicTracer.test.ts index ff44b9219b..44af7ba31e 100644 --- a/packages/opentelemetry-tracing/test/BasicTracer.test.ts +++ b/packages/opentelemetry-tracing/test/BasicTracer.test.ts @@ -251,10 +251,10 @@ describe('BasicTracer', () => { const tracer = new BasicTracer({ sampler: NEVER_SAMPLER, }); - const span = tracer.startSpan('my-span', { isRecordingEvents: true }); + const span = tracer.startSpan('my-span', { isRecording: true }); assert.ok(span instanceof Span); assert.strictEqual(span.context().traceFlags, TraceFlags.UNSAMPLED); - assert.strictEqual(span.isRecordingEvents(), true); + assert.strictEqual(span.isRecording(), true); }); it('should not create real span when not sampled and recording events false', () => { @@ -262,10 +262,10 @@ describe('BasicTracer', () => { sampler: NEVER_SAMPLER, logger: new NoopLogger(), }); - const span = tracer.startSpan('my-span', { isRecordingEvents: false }); + const span = tracer.startSpan('my-span', { isRecording: false }); assert.ok(span instanceof NoRecordingSpan); assert.strictEqual(span.context().traceFlags, TraceFlags.UNSAMPLED); - assert.strictEqual(span.isRecordingEvents(), false); + assert.strictEqual(span.isRecording(), false); }); it('should not create real span when not sampled and no recording events configured', () => { @@ -276,7 +276,7 @@ describe('BasicTracer', () => { const span = tracer.startSpan('my-span'); assert.ok(span instanceof NoRecordingSpan); assert.strictEqual(span.context().traceFlags, TraceFlags.UNSAMPLED); - assert.strictEqual(span.isRecordingEvents(), false); + assert.strictEqual(span.isRecording(), false); }); it('should create real span when sampled and recording events true', () => { @@ -284,10 +284,10 @@ describe('BasicTracer', () => { sampler: ALWAYS_SAMPLER, scopeManager: new NoopScopeManager(), }); - const span = tracer.startSpan('my-span', { isRecordingEvents: true }); + const span = tracer.startSpan('my-span', { isRecording: true }); assert.ok(span instanceof Span); assert.strictEqual(span.context().traceFlags, TraceFlags.SAMPLED); - assert.strictEqual(span.isRecordingEvents(), true); + assert.strictEqual(span.isRecording(), true); }); it('should set default attributes on span', () => { diff --git a/packages/opentelemetry-tracing/test/Span.test.ts b/packages/opentelemetry-tracing/test/Span.test.ts index 79997a8e90..45b9650876 100644 --- a/packages/opentelemetry-tracing/test/Span.test.ts +++ b/packages/opentelemetry-tracing/test/Span.test.ts @@ -93,13 +93,13 @@ describe('Span', () => { assert.strictEqual(context.traceFlags, TraceFlags.SAMPLED); assert.strictEqual(context.traceState, undefined); assert.ok(context.spanId.match(/[a-f0-9]{16}/)); - assert.ok(span.isRecordingEvents()); + assert.ok(span.isRecording()); span.end(); }); - it('should return true when isRecordingEvents:true', () => { + it('should return true when isRecording:true', () => { const span = new Span(tracer, name, spanContext, SpanKind.CLIENT); - assert.ok(span.isRecordingEvents()); + assert.ok(span.isRecording()); span.end(); }); diff --git a/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts b/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts index 1ebbe468e9..e4ef7f55ef 100644 --- a/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts +++ b/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts @@ -37,7 +37,7 @@ function createUnSampledSpan(spanName: string): Span { sampler: NEVER_SAMPLER, logger: new NoopLogger(), }); - const span = tracer.startSpan(spanName, { isRecordingEvents: false }); + const span = tracer.startSpan(spanName, { isRecording: false }); span.end(); return span as Span; } diff --git a/packages/opentelemetry-types/src/trace/SpanOptions.ts b/packages/opentelemetry-types/src/trace/SpanOptions.ts index aa84497dfe..778c7166f2 100644 --- a/packages/opentelemetry-types/src/trace/SpanOptions.ts +++ b/packages/opentelemetry-types/src/trace/SpanOptions.ts @@ -30,7 +30,7 @@ export interface SpanOptions { attributes?: Attributes; /** Indicates that events are being recorded for a span */ - isRecordingEvents?: boolean; + isRecording?: boolean; /** * A parent SpanContext (or Span, for convenience) that the newly-started diff --git a/packages/opentelemetry-types/src/trace/span.ts b/packages/opentelemetry-types/src/trace/span.ts index 0db3ef4e0d..fd0e4cf12a 100644 --- a/packages/opentelemetry-types/src/trace/span.ts +++ b/packages/opentelemetry-types/src/trace/span.ts @@ -102,5 +102,5 @@ export interface Span { * @returns true if this Span is active and recording information like events * with the AddEvent operation and attributes using setAttributes. */ - isRecordingEvents(): boolean; + isRecording(): boolean; } From 58e387915e30cf5845c7b2feaead7b2f82a799b7 Mon Sep 17 00:00:00 2001 From: Xiao Date: Tue, 22 Oct 2019 15:57:01 -0700 Subject: [PATCH 2/3] Update packages/opentelemetry-types/src/trace/SpanOptions.ts Co-Authored-By: Mayur Kale --- packages/opentelemetry-types/src/trace/SpanOptions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opentelemetry-types/src/trace/SpanOptions.ts b/packages/opentelemetry-types/src/trace/SpanOptions.ts index 778c7166f2..0c0797d612 100644 --- a/packages/opentelemetry-types/src/trace/SpanOptions.ts +++ b/packages/opentelemetry-types/src/trace/SpanOptions.ts @@ -29,7 +29,7 @@ export interface SpanOptions { /** A spans attributes */ attributes?: Attributes; - /** Indicates that events are being recorded for a span */ + /** Indicates that if this Span is active and recording information like events with the `AddEvent` operation and attributes using `setAttributes`. */ isRecording?: boolean; /** From ae5cf124a20d12bf238f930790fefeb80f74ca94 Mon Sep 17 00:00:00 2001 From: xiao-lix Date: Tue, 22 Oct 2019 16:14:44 -0700 Subject: [PATCH 3/3] fix: linting errors --- packages/opentelemetry-types/src/trace/SpanOptions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opentelemetry-types/src/trace/SpanOptions.ts b/packages/opentelemetry-types/src/trace/SpanOptions.ts index 0c0797d612..c396d2df46 100644 --- a/packages/opentelemetry-types/src/trace/SpanOptions.ts +++ b/packages/opentelemetry-types/src/trace/SpanOptions.ts @@ -29,7 +29,7 @@ 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`. */ + /** Indicates that if this Span is active and recording information like events with the `AddEvent` operation and attributes using `setAttributes`. */ isRecording?: boolean; /**