Skip to content

Commit fda147f

Browse files
authored
Merge 42c0fbe into 2f0d612
2 parents 2f0d612 + 42c0fbe commit fda147f

File tree

9 files changed

+14
-105
lines changed

9 files changed

+14
-105
lines changed

packages/opentelemetry-core/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export * from './context/propagation/HttpTraceContext';
2727
export * from './context/propagation/types';
2828
export * from './baggage/propagation/HttpBaggage';
2929
export * from './platform';
30-
export * from './trace/NoRecordingSpan';
3130
export * from './trace/Plugin';
3231
export * from './trace/sampler/AlwaysOffSampler';
3332
export * from './trace/sampler/AlwaysOnSampler';

packages/opentelemetry-core/src/trace/NoRecordingSpan.ts

-39
This file was deleted.

packages/opentelemetry-core/test/trace/NoRecordingSpan.test.ts

-33
This file was deleted.

packages/opentelemetry-instrumentation-http/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"devDependencies": {
4444
"@opentelemetry/context-async-hooks": "^0.16.0",
4545
"@opentelemetry/context-base": "^0.16.0",
46+
"@opentelemetry/core": "^0.16.0",
4647
"@opentelemetry/node": "^0.16.0",
4748
"@opentelemetry/tracing": "^0.16.0",
4849
"@types/got": "9.6.11",
@@ -70,7 +71,6 @@
7071
},
7172
"dependencies": {
7273
"@opentelemetry/api": "^0.16.0",
73-
"@opentelemetry/core": "^0.16.0",
7474
"@opentelemetry/instrumentation": "^0.16.0",
7575
"@opentelemetry/semantic-conventions": "^0.16.0",
7676
"semver": "^7.1.3"

packages/opentelemetry-instrumentation-http/src/http.ts

+3-10
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ import {
2222
SpanOptions,
2323
SpanStatus,
2424
setSpan,
25-
SpanContext,
26-
TraceFlags,
2725
ROOT_CONTEXT,
2826
getSpan,
2927
suppressInstrumentation,
28+
NoopSpan,
3029
} from '@opentelemetry/api';
31-
import { NoRecordingSpan } from '@opentelemetry/core';
3230
import type * as http from 'http';
3331
import type * as https from 'https';
3432
import { Socket } from 'net';
@@ -61,11 +59,6 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
6159
/** keep track on spans not ended */
6260
private readonly _spanNotEnded: WeakSet<Span> = new WeakSet<Span>();
6361
private readonly _version = process.versions.node;
64-
private readonly _emptySpanContext: SpanContext = {
65-
traceId: '',
66-
spanId: '',
67-
traceFlags: TraceFlags.NONE,
68-
};
6962

7063
constructor(config: HttpInstrumentationConfig & InstrumentationConfig = {}) {
7164
super(
@@ -580,7 +573,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
580573

581574
private _startHttpSpan(name: string, options: SpanOptions) {
582575
/*
583-
* If a parent is required but not present, we use a `NoRecordingSpan` to still
576+
* If a parent is required but not present, we use a `NoopSpan` to still
584577
* propagate context without recording it.
585578
*/
586579
const requireParent =
@@ -594,7 +587,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
594587
if (requireParent === true && currentSpan === undefined) {
595588
// TODO: Refactor this when a solution is found in
596589
// https://github.com/open-telemetry/opentelemetry-specification/issues/530
597-
span = new NoRecordingSpan(this._emptySpanContext);
590+
span = new NoopSpan();
598591
} else if (requireParent === true && currentSpan?.context().isRemote) {
599592
span = currentSpan;
600593
} else {

packages/opentelemetry-node/test/NodeTracerProvider.test.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@ import {
2121
setSpan,
2222
setSpanContext,
2323
getSpan,
24+
NoopSpan,
2425
} from '@opentelemetry/api';
25-
import {
26-
AlwaysOnSampler,
27-
AlwaysOffSampler,
28-
NoRecordingSpan,
29-
} from '@opentelemetry/core';
26+
import { AlwaysOnSampler, AlwaysOffSampler } from '@opentelemetry/core';
3027
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
3128
import { Span } from '@opentelemetry/tracing';
3229
import { Resource, TELEMETRY_SDK_RESOURCE } from '@opentelemetry/resources';
@@ -124,7 +121,7 @@ describe('NodeTracerProvider', () => {
124121
logger: new NoopLogger(),
125122
});
126123
const span = provider.getTracer('default').startSpan('my-span');
127-
assert.ok(span instanceof NoRecordingSpan);
124+
assert.ok(span instanceof NoopSpan);
128125
assert.strictEqual(span.context().traceFlags, TraceFlags.NONE);
129126
assert.strictEqual(span.isRecording(), false);
130127
});

packages/opentelemetry-plugin-http/src/http.ts

+4-11
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ import {
2121
SpanKind,
2222
SpanOptions,
2323
SpanStatus,
24-
SpanContext,
25-
TraceFlags,
2624
setSpan,
2725
ROOT_CONTEXT,
2826
getSpan,
2927
suppressInstrumentation,
28+
NoopSpan,
3029
} from '@opentelemetry/api';
31-
import { BasePlugin, NoRecordingSpan } from '@opentelemetry/core';
30+
import { BasePlugin } from '@opentelemetry/core';
3231
import type {
3332
ClientRequest,
3433
IncomingMessage,
@@ -60,12 +59,6 @@ export class HttpPlugin extends BasePlugin<Http> {
6059
/** keep track on spans not ended */
6160
private readonly _spanNotEnded: WeakSet<Span>;
6261

63-
private readonly _emptySpanContext: SpanContext = {
64-
traceId: '',
65-
spanId: '',
66-
traceFlags: TraceFlags.NONE,
67-
};
68-
6962
constructor(readonly moduleName: string, readonly version: string) {
7063
super(`@opentelemetry/plugin-${moduleName}`, VERSION);
7164
// For now component is equal to moduleName but it can change in the future.
@@ -439,7 +432,7 @@ export class HttpPlugin extends BasePlugin<Http> {
439432

440433
private _startHttpSpan(name: string, options: SpanOptions) {
441434
/*
442-
* If a parent is required but not present, we use a `NoRecordingSpan` to still
435+
* If a parent is required but not present, we use a `NoopSpan` to still
443436
* propagate context without recording it.
444437
*/
445438
const requireParent =
@@ -453,7 +446,7 @@ export class HttpPlugin extends BasePlugin<Http> {
453446
if (requireParent === true && currentSpan === undefined) {
454447
// TODO: Refactor this when a solution is found in
455448
// https://github.com/open-telemetry/opentelemetry-specification/issues/530
456-
span = new NoRecordingSpan(plugin._emptySpanContext);
449+
span = new NoopSpan();
457450
} else if (requireParent === true && currentSpan?.context().isRemote) {
458451
span = currentSpan;
459452
} else {

packages/opentelemetry-tracing/src/Tracer.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import * as api from '@opentelemetry/api';
1818
import {
1919
ConsoleLogger,
2020
InstrumentationLibrary,
21-
NoRecordingSpan,
2221
IdGenerator,
2322
RandomIdGenerator,
2423
sanitizeAttributes,
@@ -104,7 +103,7 @@ export class Tracer implements api.Tracer {
104103
const spanContext = { traceId, spanId, traceFlags, traceState };
105104
if (samplingResult.decision === api.SamplingDecision.NOT_RECORD) {
106105
this.logger.debug('Recording is off, starting no recording span');
107-
return new NoRecordingSpan(spanContext);
106+
return new api.NoopSpan(spanContext);
108107
}
109108

110109
const span = new Span(

packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ import {
2020
TraceFlags,
2121
ROOT_CONTEXT,
2222
NoopLogger,
23+
NoopSpan,
2324
setSpan,
2425
setSpanContext,
2526
getSpan,
2627
} from '@opentelemetry/api';
2728
import {
2829
AlwaysOnSampler,
2930
AlwaysOffSampler,
30-
NoRecordingSpan,
3131
TraceState,
3232
} from '@opentelemetry/core';
3333
import { Resource } from '@opentelemetry/resources';
@@ -264,7 +264,7 @@ describe('BasicTracerProvider', () => {
264264
logger: new NoopLogger(),
265265
}).getTracer('default');
266266
const span = tracer.startSpan('my-span');
267-
assert.ok(span instanceof NoRecordingSpan);
267+
assert.ok(span instanceof NoopSpan);
268268
const context = span.context();
269269
assert.ok(context.traceId.match(/[a-f0-9]{32}/));
270270
assert.ok(context.spanId.match(/[a-f0-9]{16}/));

0 commit comments

Comments
 (0)