Skip to content

Commit

Permalink
chore: remove SpanOptions.isRecording (open-telemetry#817)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Flarna authored Mar 4, 2020
1 parent 5a5b6b8 commit 4127913
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 43 deletions.
6 changes: 0 additions & 6 deletions packages/opentelemetry-api/src/trace/SpanOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('NoopTracer', () => {
assert.deepStrictEqual(
tracer.startSpan('span-name2', {
kind: SpanKind.CLIENT,
isRecording: true,
}),
NOOP_SPAN
);
Expand Down
3 changes: 1 addition & 2 deletions packages/opentelemetry-tracing/src/Tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
36 changes: 2 additions & 34 deletions packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4127913

Please sign in to comment.