Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

chore: renaming noop span to non recording span #43

Merged
merged 3 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ main();

Because the npm installer and node module resolution algorithm could potentially allow two or more copies of any given package to exist within the same `node_modules` structure, the OpenTelemetry API takes advantage of a variable on the `global` object to store the global API. When an API method in the API package is called, it checks if this `global` API exists and proxies calls to it if and only if it is a compatible API version. This means if a package has a dependency on an OpenTelemetry API version which is not compatible with the API used by the end user, the package will receive a no-op implementation of the API.

## Upgrade guidelines

### 1.0.0-rc.0 to x

- `HttpBaggage` renamed to `HttpBaggagePropagator`

## Useful links

- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
Expand Down
6 changes: 3 additions & 3 deletions src/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { Context } from './types';
import { Baggage, Span, SpanContext } from '../';
import { NoopSpan } from '../trace/NoopSpan';
import { NonRecordingSpan } from '../trace/NonRecordingSpan';

/**
* span key
Expand Down Expand Up @@ -56,7 +56,7 @@ export function setSpan(context: Context, span: Span): Context {
}

/**
* Wrap span context in a NoopSpan and set as span in a new
* Wrap span context in a NonRecordingSpan and set as span in a new
* context
*
* @param context context to set active span on
Expand All @@ -66,7 +66,7 @@ export function setSpanContext(
context: Context,
spanContext: SpanContext
): Context {
return setSpan(context, new NoopSpan(spanContext));
return setSpan(context, new NonRecordingSpan(spanContext));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/trace/NoopSpan.ts → src/trace/NonRecordingSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { SpanStatus } from './status';
import { INVALID_SPAN_CONTEXT } from './spancontext-utils';

/**
* The NoopSpan is the default {@link Span} that is used when no Span
* The NonRecordingSpan is the default {@link Span} that is used when no Span
* implementation is available. All operations are no-op including context
* propagation.
*/
export class NoopSpan implements Span {
export class NonRecordingSpan implements Span {
constructor(
private readonly _spanContext: SpanContext = INVALID_SPAN_CONTEXT
) {}
Expand Down Expand Up @@ -65,7 +65,7 @@ export class NoopSpan implements Span {
// By default does nothing
end(_endTime?: TimeInput): void {}

// isRecording always returns false for noopSpan.
// isRecording always returns false for NonRecordingSpan.
isRecording(): boolean {
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/trace/NoopTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { getSpanContext } from '../context/context';
import { Context } from '../context/types';
import { NoopSpan } from './NoopSpan';
import { NonRecordingSpan } from './NonRecordingSpan';
import { Span } from './span';
import { isSpanContextValid } from './spancontext-utils';
import { SpanOptions } from './SpanOptions';
Expand All @@ -31,7 +31,7 @@ export class NoopTracer implements Tracer {
startSpan(name: string, options?: SpanOptions, context?: Context): Span {
const root = Boolean(options?.root);
if (root) {
return new NoopSpan();
return new NonRecordingSpan();
}

const parentFromContext = context && getSpanContext(context);
Expand All @@ -40,9 +40,9 @@ export class NoopTracer implements Tracer {
isSpanContext(parentFromContext) &&
isSpanContextValid(parentFromContext)
) {
return new NoopSpan(parentFromContext);
return new NonRecordingSpan(parentFromContext);
} else {
return new NoopSpan();
return new NonRecordingSpan();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/api/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import api, {
diag,
} from '../../src';
import { DiagAPI } from '../../src/api/diag';
import { NoopSpan } from '../../src/trace/NoopSpan';
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';

// DiagLogger implementation
const diagLoggerFunctions = [
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('API', () => {
spanId: '6e0c63257de34c92',
traceFlags: TraceFlags.NONE,
};
const dummySpan = new NoopSpan(spanContext);
const dummySpan = new NonRecordingSpan(spanContext);

beforeEach(() => {
context.disable();
Expand Down
6 changes: 3 additions & 3 deletions test/noop-implementations/noop-span.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import {
INVALID_TRACEID,
TraceFlags,
} from '../../src';
import { NoopSpan } from '../../src/trace/NoopSpan';
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';

describe('NoopSpan', () => {
describe('NonRecordingSpan', () => {
it('do not crash', () => {
const span = new NoopSpan();
const span = new NonRecordingSpan();
span.setAttribute('my_string_attribute', 'foo');
span.setAttribute('my_number_attribute', 123);
span.setAttribute('my_boolean_attribute', false);
Expand Down
8 changes: 4 additions & 4 deletions test/noop-implementations/noop-tracer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ import {
context,
setSpanContext,
} from '../../src';
import { NoopSpan } from '../../src/trace/NoopSpan';
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';

describe('NoopTracer', () => {
it('should not crash', () => {
const tracer = new NoopTracer();

assert.ok(tracer.startSpan('span-name') instanceof NoopSpan);
assert.ok(tracer.startSpan('span-name') instanceof NonRecordingSpan);
assert.ok(
tracer.startSpan('span-name1', { kind: SpanKind.CLIENT }) instanceof
NoopSpan
NonRecordingSpan
);
assert.ok(
tracer.startSpan('span-name2', { kind: SpanKind.CLIENT }) instanceof
NoopSpan
NonRecordingSpan
);
});

Expand Down
10 changes: 5 additions & 5 deletions test/proxy-implementations/proxy-tracer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
ROOT_CONTEXT,
SpanOptions,
} from '../../src';
import { NoopSpan } from '../../src/trace/NoopSpan';
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';

describe('ProxyTracer', () => {
let provider: ProxyTracerProvider;
Expand All @@ -51,14 +51,14 @@ describe('ProxyTracer', () => {
it('startSpan should return Noop Spans', () => {
const tracer = provider.getTracer('test');

assert.ok(tracer.startSpan('span-name') instanceof NoopSpan);
assert.ok(tracer.startSpan('span-name') instanceof NonRecordingSpan);
assert.ok(
tracer.startSpan('span-name1', { kind: SpanKind.CLIENT }) instanceof
NoopSpan
NonRecordingSpan
);
assert.ok(
tracer.startSpan('span-name2', { kind: SpanKind.CLIENT }) instanceof
NoopSpan
NonRecordingSpan
);
});
});
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('ProxyTracer', () => {
let delegateTracer: Tracer;

beforeEach(() => {
delegateSpan = new NoopSpan();
delegateSpan = new NonRecordingSpan();
delegateTracer = {
startSpan() {
return delegateSpan;
Expand Down