Skip to content

Commit

Permalink
fix(span): rename span recording flag (open-telemetry#454)
Browse files Browse the repository at this point in the history
* fix(span): rename span recording flag

* Update packages/opentelemetry-types/src/trace/SpanOptions.ts

Co-Authored-By: Mayur Kale <[email protected]>

* fix: linting errors
  • Loading branch information
xiao-lix authored and mayurkale22 committed Oct 22, 2019
1 parent 2848296 commit 972faa2
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions packages/opentelemetry-core/src/trace/NoopSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-core/test/trace/NoopSpan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-core/test/trace/NoopTracer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('NoopTracer', () => {
assert.deepStrictEqual(
tracer.startSpan('span-name2', {
kind: SpanKind.CLIENT,
isRecordingEvents: true,
isRecording: true,
}),
NOOP_SPAN
);
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-node/test/NodeTracer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-tracing/src/BasicTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-tracing/src/Span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class Span implements types.Span, ReadableSpan {
this._spanProcessor.onEnd(this);
}

isRecordingEvents(): boolean {
isRecording(): boolean {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-tracing/src/SpanProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
14 changes: 7 additions & 7 deletions packages/opentelemetry-tracing/test/BasicTracer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,21 @@ 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', () => {
const tracer = new 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', () => {
Expand All @@ -276,18 +276,18 @@ 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', () => {
const tracer = new 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', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/opentelemetry-tracing/test/Span.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-types/src/trace/SpanOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export interface SpanOptions {
/** A spans attributes */
attributes?: Attributes;

/** Indicates that events are being recorded for a span */
isRecordingEvents?: boolean;
/** Indicates that if this Span is active and recording information like events with the `AddEvent` operation and attributes using `setAttributes`. */
isRecording?: boolean;

/**
* A parent SpanContext (or Span, for convenience) that the newly-started
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-types/src/trace/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 972faa2

Please sign in to comment.