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

Commit c1f302e

Browse files
authored
chore: renaming noop span to non recording span (#43)
* chore: renaming noop span to non recording span * chore: adding upgrade guidelines fixing links
1 parent 9fba460 commit c1f302e

File tree

8 files changed

+30
-24
lines changed

8 files changed

+30
-24
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ main();
103103

104104
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.
105105

106+
## Upgrade guidelines
107+
108+
### 1.0.0-rc.0 to x
109+
110+
- `HttpBaggage` renamed to `HttpBaggagePropagator`
111+
106112
## Useful links
107113

108114
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>

src/context/context.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { Context } from './types';
1818
import { Baggage, Span, SpanContext } from '../';
19-
import { NoopSpan } from '../trace/NoopSpan';
19+
import { NonRecordingSpan } from '../trace/NonRecordingSpan';
2020

2121
/**
2222
* span key
@@ -56,7 +56,7 @@ export function setSpan(context: Context, span: Span): Context {
5656
}
5757

5858
/**
59-
* Wrap span context in a NoopSpan and set as span in a new
59+
* Wrap span context in a NonRecordingSpan and set as span in a new
6060
* context
6161
*
6262
* @param context context to set active span on
@@ -66,7 +66,7 @@ export function setSpanContext(
6666
context: Context,
6767
spanContext: SpanContext
6868
): Context {
69-
return setSpan(context, new NoopSpan(spanContext));
69+
return setSpan(context, new NonRecordingSpan(spanContext));
7070
}
7171

7272
/**

src/trace/NoopSpan.ts renamed to src/trace/NonRecordingSpan.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import { SpanStatus } from './status';
2323
import { INVALID_SPAN_CONTEXT } from './spancontext-utils';
2424

2525
/**
26-
* The NoopSpan is the default {@link Span} that is used when no Span
26+
* The NonRecordingSpan is the default {@link Span} that is used when no Span
2727
* implementation is available. All operations are no-op including context
2828
* propagation.
2929
*/
30-
export class NoopSpan implements Span {
30+
export class NonRecordingSpan implements Span {
3131
constructor(
3232
private readonly _spanContext: SpanContext = INVALID_SPAN_CONTEXT
3333
) {}
@@ -65,7 +65,7 @@ export class NoopSpan implements Span {
6565
// By default does nothing
6666
end(_endTime?: TimeInput): void {}
6767

68-
// isRecording always returns false for noopSpan.
68+
// isRecording always returns false for NonRecordingSpan.
6969
isRecording(): boolean {
7070
return false;
7171
}

src/trace/NoopTracer.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { getSpanContext } from '../context/context';
1818
import { Context } from '../context/types';
19-
import { NoopSpan } from './NoopSpan';
19+
import { NonRecordingSpan } from './NonRecordingSpan';
2020
import { Span } from './span';
2121
import { isSpanContextValid } from './spancontext-utils';
2222
import { SpanOptions } from './SpanOptions';
@@ -31,7 +31,7 @@ export class NoopTracer implements Tracer {
3131
startSpan(name: string, options?: SpanOptions, context?: Context): Span {
3232
const root = Boolean(options?.root);
3333
if (root) {
34-
return new NoopSpan();
34+
return new NonRecordingSpan();
3535
}
3636

3737
const parentFromContext = context && getSpanContext(context);
@@ -40,9 +40,9 @@ export class NoopTracer implements Tracer {
4040
isSpanContext(parentFromContext) &&
4141
isSpanContextValid(parentFromContext)
4242
) {
43-
return new NoopSpan(parentFromContext);
43+
return new NonRecordingSpan(parentFromContext);
4444
} else {
45-
return new NoopSpan();
45+
return new NonRecordingSpan();
4646
}
4747
}
4848
}

test/api/api.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import api, {
3434
diag,
3535
} from '../../src';
3636
import { DiagAPI } from '../../src/api/diag';
37-
import { NoopSpan } from '../../src/trace/NoopSpan';
37+
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';
3838

3939
// DiagLogger implementation
4040
const diagLoggerFunctions = [
@@ -78,7 +78,7 @@ describe('API', () => {
7878
spanId: '6e0c63257de34c92',
7979
traceFlags: TraceFlags.NONE,
8080
};
81-
const dummySpan = new NoopSpan(spanContext);
81+
const dummySpan = new NonRecordingSpan(spanContext);
8282

8383
beforeEach(() => {
8484
context.disable();

test/noop-implementations/noop-span.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import {
2121
INVALID_TRACEID,
2222
TraceFlags,
2323
} from '../../src';
24-
import { NoopSpan } from '../../src/trace/NoopSpan';
24+
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';
2525

26-
describe('NoopSpan', () => {
26+
describe('NonRecordingSpan', () => {
2727
it('do not crash', () => {
28-
const span = new NoopSpan();
28+
const span = new NonRecordingSpan();
2929
span.setAttribute('my_string_attribute', 'foo');
3030
span.setAttribute('my_number_attribute', 123);
3131
span.setAttribute('my_boolean_attribute', false);

test/noop-implementations/noop-tracer.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ import {
2323
context,
2424
setSpanContext,
2525
} from '../../src';
26-
import { NoopSpan } from '../../src/trace/NoopSpan';
26+
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';
2727

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

32-
assert.ok(tracer.startSpan('span-name') instanceof NoopSpan);
32+
assert.ok(tracer.startSpan('span-name') instanceof NonRecordingSpan);
3333
assert.ok(
3434
tracer.startSpan('span-name1', { kind: SpanKind.CLIENT }) instanceof
35-
NoopSpan
35+
NonRecordingSpan
3636
);
3737
assert.ok(
3838
tracer.startSpan('span-name2', { kind: SpanKind.CLIENT }) instanceof
39-
NoopSpan
39+
NonRecordingSpan
4040
);
4141
});
4242

test/proxy-implementations/proxy-tracer.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
ROOT_CONTEXT,
2828
SpanOptions,
2929
} from '../../src';
30-
import { NoopSpan } from '../../src/trace/NoopSpan';
30+
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';
3131

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

54-
assert.ok(tracer.startSpan('span-name') instanceof NoopSpan);
54+
assert.ok(tracer.startSpan('span-name') instanceof NonRecordingSpan);
5555
assert.ok(
5656
tracer.startSpan('span-name1', { kind: SpanKind.CLIENT }) instanceof
57-
NoopSpan
57+
NonRecordingSpan
5858
);
5959
assert.ok(
6060
tracer.startSpan('span-name2', { kind: SpanKind.CLIENT }) instanceof
61-
NoopSpan
61+
NonRecordingSpan
6262
);
6363
});
6464
});
@@ -91,7 +91,7 @@ describe('ProxyTracer', () => {
9191
let delegateTracer: Tracer;
9292

9393
beforeEach(() => {
94-
delegateSpan = new NoopSpan();
94+
delegateSpan = new NonRecordingSpan();
9595
delegateTracer = {
9696
startSpan() {
9797
return delegateSpan;

0 commit comments

Comments
 (0)