diff --git a/packages/opentelemetry-api/src/api/global-utils.ts b/packages/opentelemetry-api/src/api/global-utils.ts index a294f345d5..407399c8fb 100644 --- a/packages/opentelemetry-api/src/api/global-utils.ts +++ b/packages/opentelemetry-api/src/api/global-utils.ts @@ -15,7 +15,7 @@ */ import { ContextManager } from '@opentelemetry/context-base'; -import { HttpTextPropagator } from '../context/propagation/HttpTextPropagator'; +import { TextMapPropagator } from '../context/propagation/TextMapPropagator'; import { MeterProvider } from '../metrics/MeterProvider'; import { TracerProvider } from '../trace/tracer_provider'; import { _globalThis } from '../platform'; @@ -35,7 +35,7 @@ type Get = (version: number) => T; type OtelGlobal = Partial<{ [GLOBAL_CONTEXT_MANAGER_API_KEY]: Get; [GLOBAL_METRICS_API_KEY]: Get; - [GLOBAL_PROPAGATION_API_KEY]: Get; + [GLOBAL_PROPAGATION_API_KEY]: Get; [GLOBAL_TRACE_API_KEY]: Get; }>; diff --git a/packages/opentelemetry-api/src/api/propagation.ts b/packages/opentelemetry-api/src/api/propagation.ts index 989e497b66..92a046a659 100644 --- a/packages/opentelemetry-api/src/api/propagation.ts +++ b/packages/opentelemetry-api/src/api/propagation.ts @@ -16,8 +16,8 @@ import { Context } from '@opentelemetry/context-base'; import { defaultGetter, GetterFunction } from '../context/propagation/getter'; -import { HttpTextPropagator } from '../context/propagation/HttpTextPropagator'; -import { NOOP_HTTP_TEXT_PROPAGATOR } from '../context/propagation/NoopHttpTextPropagator'; +import { TextMapPropagator } from '../context/propagation/TextMapPropagator'; +import { NOOP_TEXT_MAP_PROPAGATOR } from '../context/propagation/NoopTextMapPropagator'; import { defaultSetter, SetterFunction } from '../context/propagation/setter'; import { ContextAPI } from './context'; import { @@ -50,9 +50,7 @@ export class PropagationAPI { /** * Set the current propagator. Returns the initialized propagator */ - public setGlobalPropagator( - propagator: HttpTextPropagator - ): HttpTextPropagator { + public setGlobalPropagator(propagator: TextMapPropagator): TextMapPropagator { if (_global[GLOBAL_PROPAGATION_API_KEY]) { // global propagator has already been set return this._getGlobalPropagator(); @@ -61,7 +59,7 @@ export class PropagationAPI { _global[GLOBAL_PROPAGATION_API_KEY] = makeGetter( API_BACKWARDS_COMPATIBILITY_VERSION, propagator, - NOOP_HTTP_TEXT_PROPAGATOR + NOOP_TEXT_MAP_PROPAGATOR ); return propagator; @@ -102,11 +100,11 @@ export class PropagationAPI { delete _global[GLOBAL_PROPAGATION_API_KEY]; } - private _getGlobalPropagator(): HttpTextPropagator { + private _getGlobalPropagator(): TextMapPropagator { return ( _global[GLOBAL_PROPAGATION_API_KEY]?.( API_BACKWARDS_COMPATIBILITY_VERSION - ) ?? NOOP_HTTP_TEXT_PROPAGATOR + ) ?? NOOP_TEXT_MAP_PROPAGATOR ); } } diff --git a/packages/opentelemetry-api/src/context/propagation/NoopHttpTextPropagator.ts b/packages/opentelemetry-api/src/context/propagation/NoopTextMapPropagator.ts similarity index 79% rename from packages/opentelemetry-api/src/context/propagation/NoopHttpTextPropagator.ts rename to packages/opentelemetry-api/src/context/propagation/NoopTextMapPropagator.ts index 7782ba30b9..c2155fadc9 100644 --- a/packages/opentelemetry-api/src/context/propagation/NoopHttpTextPropagator.ts +++ b/packages/opentelemetry-api/src/context/propagation/NoopTextMapPropagator.ts @@ -15,12 +15,12 @@ */ import { Context } from '@opentelemetry/context-base'; -import { HttpTextPropagator } from './HttpTextPropagator'; +import { TextMapPropagator } from './TextMapPropagator'; /** - * No-op implementations of {@link HttpTextPropagator}. + * No-op implementations of {@link TextMapPropagator}. */ -export class NoopHttpTextPropagator implements HttpTextPropagator { +export class NoopTextMapPropagator implements TextMapPropagator { /** Noop inject function does nothing */ inject(context: Context, carrier: unknown, setter: Function): void {} /** Noop extract function does nothing and returns the input context */ @@ -29,4 +29,4 @@ export class NoopHttpTextPropagator implements HttpTextPropagator { } } -export const NOOP_HTTP_TEXT_PROPAGATOR = new NoopHttpTextPropagator(); +export const NOOP_TEXT_MAP_PROPAGATOR = new NoopTextMapPropagator(); diff --git a/packages/opentelemetry-api/src/context/propagation/HttpTextPropagator.ts b/packages/opentelemetry-api/src/context/propagation/TextMapPropagator.ts similarity index 95% rename from packages/opentelemetry-api/src/context/propagation/HttpTextPropagator.ts rename to packages/opentelemetry-api/src/context/propagation/TextMapPropagator.ts index 6c6f61d668..f56112495d 100644 --- a/packages/opentelemetry-api/src/context/propagation/HttpTextPropagator.ts +++ b/packages/opentelemetry-api/src/context/propagation/TextMapPropagator.ts @@ -29,11 +29,11 @@ import { GetterFunction } from './getter'; * usually implemented via library-specific request interceptors, where the * client-side injects values and the server-side extracts them. */ -export interface HttpTextPropagator { +export interface TextMapPropagator { /** * Injects values from a given `Context` into a carrier. * - * OpenTelemetry defines a common set of format values (HttpTextPropagator), + * OpenTelemetry defines a common set of format values (TextMapPropagator), * and each has an expected `carrier` type. * * @param context the Context from which to extract values to transmit over diff --git a/packages/opentelemetry-api/src/index.ts b/packages/opentelemetry-api/src/index.ts index 68dcb00029..96e9b9bb4c 100644 --- a/packages/opentelemetry-api/src/index.ts +++ b/packages/opentelemetry-api/src/index.ts @@ -18,8 +18,8 @@ export * from './common/Exception'; export * from './common/Logger'; export * from './common/Time'; export * from './context/propagation/getter'; -export * from './context/propagation/HttpTextPropagator'; -export * from './context/propagation/NoopHttpTextPropagator'; +export * from './context/propagation/TextMapPropagator'; +export * from './context/propagation/NoopTextMapPropagator'; export * from './context/propagation/setter'; export * from './correlation_context/CorrelationContext'; export * from './correlation_context/EntryValue'; diff --git a/packages/opentelemetry-core/src/context/propagation/B3Propagator.ts b/packages/opentelemetry-core/src/context/propagation/B3Propagator.ts index 129e457cb6..43da0b1189 100644 --- a/packages/opentelemetry-core/src/context/propagation/B3Propagator.ts +++ b/packages/opentelemetry-core/src/context/propagation/B3Propagator.ts @@ -17,7 +17,7 @@ import { Context, GetterFunction, - HttpTextPropagator, + TextMapPropagator, SetterFunction, TraceFlags, } from '@opentelemetry/api'; @@ -120,7 +120,7 @@ function getTraceFlags( * Propagator for the B3 HTTP header format. * Based on: https://github.com/openzipkin/b3-propagation */ -export class B3Propagator implements HttpTextPropagator { +export class B3Propagator implements TextMapPropagator { inject(context: Context, carrier: unknown, setter: SetterFunction) { const spanContext = getParentSpanContext(context); if (!spanContext) return; diff --git a/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts b/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts index c5fe4a8e7d..2ba75607d6 100644 --- a/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts +++ b/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts @@ -17,7 +17,7 @@ import { Context, GetterFunction, - HttpTextPropagator, + TextMapPropagator, SetterFunction, SpanContext, TraceFlags, @@ -83,7 +83,7 @@ export function parseTraceParent(traceParent: string): SpanContext | null { * Based on the Trace Context specification: * https://www.w3.org/TR/trace-context/ */ -export class HttpTraceContext implements HttpTextPropagator { +export class HttpTraceContext implements TextMapPropagator { inject(context: Context, carrier: unknown, setter: SetterFunction) { const spanContext = getParentSpanContext(context); if (!spanContext) return; diff --git a/packages/opentelemetry-core/src/context/propagation/composite.ts b/packages/opentelemetry-core/src/context/propagation/composite.ts index 8b5d5d0857..e0adfb585e 100644 --- a/packages/opentelemetry-core/src/context/propagation/composite.ts +++ b/packages/opentelemetry-core/src/context/propagation/composite.ts @@ -17,7 +17,7 @@ import { Context, GetterFunction, - HttpTextPropagator, + TextMapPropagator, Logger, SetterFunction, } from '@opentelemetry/api'; @@ -25,8 +25,8 @@ import { NoopLogger } from '../../common/NoopLogger'; import { CompositePropagatorConfig } from './types'; /** Combines multiple propagators into a single propagator. */ -export class CompositePropagator implements HttpTextPropagator { - private readonly _propagators: HttpTextPropagator[]; +export class CompositePropagator implements TextMapPropagator { + private readonly _propagators: TextMapPropagator[]; private readonly _logger: Logger; /** diff --git a/packages/opentelemetry-core/src/context/propagation/types.ts b/packages/opentelemetry-core/src/context/propagation/types.ts index 9b7b2213d7..490c6ee56f 100644 --- a/packages/opentelemetry-core/src/context/propagation/types.ts +++ b/packages/opentelemetry-core/src/context/propagation/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { HttpTextPropagator, Logger } from '@opentelemetry/api'; +import { TextMapPropagator, Logger } from '@opentelemetry/api'; /** Configuration object for composite propagator */ export interface CompositePropagatorConfig { @@ -23,7 +23,7 @@ export interface CompositePropagatorConfig { * list order. If a propagator later in the list writes the same context * key as a propagator earlier in the list, the later on will "win". */ - propagators?: HttpTextPropagator[]; + propagators?: TextMapPropagator[]; /** Instance of logger */ logger?: Logger; diff --git a/packages/opentelemetry-core/src/correlation-context/propagation/HttpCorrelationContext.ts b/packages/opentelemetry-core/src/correlation-context/propagation/HttpCorrelationContext.ts index 4c67accb97..c2db665176 100644 --- a/packages/opentelemetry-core/src/correlation-context/propagation/HttpCorrelationContext.ts +++ b/packages/opentelemetry-core/src/correlation-context/propagation/HttpCorrelationContext.ts @@ -18,7 +18,7 @@ import { Context, CorrelationContext, GetterFunction, - HttpTextPropagator, + TextMapPropagator, SetterFunction, } from '@opentelemetry/api'; import { @@ -49,7 +49,7 @@ type KeyPair = { * Based on the Correlation Context specification: * https://w3c.github.io/correlation-context/ */ -export class HttpCorrelationContext implements HttpTextPropagator { +export class HttpCorrelationContext implements TextMapPropagator { inject(context: Context, carrier: unknown, setter: SetterFunction) { const correlationContext = getCorrelationContext(context); if (!correlationContext) return; diff --git a/packages/opentelemetry-core/test/context/composite.test.ts b/packages/opentelemetry-core/test/context/composite.test.ts index a26c6c5ac3..6047f40fba 100644 --- a/packages/opentelemetry-core/test/context/composite.test.ts +++ b/packages/opentelemetry-core/test/context/composite.test.ts @@ -17,7 +17,7 @@ import { defaultGetter, defaultSetter, - HttpTextPropagator, + TextMapPropagator, SpanContext, } from '@opentelemetry/api'; import { Context } from '@opentelemetry/context-base'; @@ -154,7 +154,7 @@ describe('Composite Propagator', () => { }); }); -class ThrowingPropagator implements HttpTextPropagator { +class ThrowingPropagator implements TextMapPropagator { inject(context: Context, carrier: unknown) { throw new Error('this propagator throws'); } diff --git a/packages/opentelemetry-node/test/registration.test.ts b/packages/opentelemetry-node/test/registration.test.ts index af4f08183c..2e031fd6b1 100644 --- a/packages/opentelemetry-node/test/registration.test.ts +++ b/packages/opentelemetry-node/test/registration.test.ts @@ -16,7 +16,7 @@ import { context, - NoopHttpTextPropagator, + NoopTextMapPropagator, propagation, trace, } from '@opentelemetry/api'; @@ -50,7 +50,7 @@ describe('API registration', () => { const tracerProvider = new NodeTracerProvider(); const contextManager = new NoopContextManager(); - const propagator = new NoopHttpTextPropagator(); + const propagator = new NoopTextMapPropagator(); tracerProvider.register({ contextManager, @@ -84,7 +84,7 @@ describe('API registration', () => { }); assert.ok( - propagation['_getGlobalPropagator']() instanceof NoopHttpTextPropagator + propagation['_getGlobalPropagator']() instanceof NoopTextMapPropagator ); assert.ok( diff --git a/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts b/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts index fe7ef01e51..0c787501a9 100644 --- a/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts +++ b/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Context, HttpTextPropagator, TraceFlags } from '@opentelemetry/api'; +import { Context, TextMapPropagator, TraceFlags } from '@opentelemetry/api'; import { getParentSpanContext, setExtractedSpanContext, } from '@opentelemetry/core'; import * as http from 'http'; -export class DummyPropagation implements HttpTextPropagator { +export class DummyPropagation implements TextMapPropagator { static TRACE_CONTEXT_KEY = 'x-dummy-trace-id'; static SPAN_CONTEXT_KEY = 'x-dummy-span-id'; extract(context: Context, carrier: http.OutgoingHttpHeaders) { diff --git a/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts b/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts index 906efe7968..4acd3835dc 100644 --- a/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts +++ b/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Context, HttpTextPropagator, TraceFlags } from '@opentelemetry/api'; +import { Context, TextMapPropagator, TraceFlags } from '@opentelemetry/api'; import { setExtractedSpanContext, getParentSpanContext, } from '@opentelemetry/core'; import * as http from 'http'; -export class DummyPropagation implements HttpTextPropagator { +export class DummyPropagation implements TextMapPropagator { static TRACE_CONTEXT_KEY = 'x-dummy-trace-id'; static SPAN_CONTEXT_KEY = 'x-dummy-span-id'; extract(context: Context, carrier: http.OutgoingHttpHeaders) { diff --git a/packages/opentelemetry-sdk-node/README.md b/packages/opentelemetry-sdk-node/README.md index 2db342d0d7..a2cf4318a4 100644 --- a/packages/opentelemetry-sdk-node/README.md +++ b/packages/opentelemetry-sdk-node/README.md @@ -76,7 +76,7 @@ Detect resources automatically from the environment using the default resource d Use a custom context manager. Default: [AsyncHooksContextManager](../opentelemetry-context-async-hooks/README.md) -### httpTextPropagator +### textMapPropagator Use a custom propagator. Default: [CompositePropagator](../opentelemetry-core/src/context/propagation/composite.ts) using [W3C Trace Context](../opentelemetry-core/README.md#httptracecontext-propagator) and [Correlation Context](../opentelemetry-core/README.md#correlation-context-propagator) diff --git a/packages/opentelemetry-sdk-node/src/sdk.ts b/packages/opentelemetry-sdk-node/src/sdk.ts index 3ab7d614e2..a411ab85df 100644 --- a/packages/opentelemetry-sdk-node/src/sdk.ts +++ b/packages/opentelemetry-sdk-node/src/sdk.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { HttpTextPropagator, metrics } from '@opentelemetry/api'; +import { TextMapPropagator, metrics } from '@opentelemetry/api'; import { ContextManager } from '@opentelemetry/context-base'; import { MeterConfig, MeterProvider } from '@opentelemetry/metrics'; import { NodeTracerConfig, NodeTracerProvider } from '@opentelemetry/node'; @@ -35,7 +35,7 @@ export class NodeSDK { tracerConfig: NodeTracerConfig; spanProcessor: SpanProcessor; contextManager?: ContextManager; - httpTextPropagator?: HttpTextPropagator; + textMapPropagator?: TextMapPropagator; }; private _meterProviderConfig?: MeterConfig; @@ -78,7 +78,7 @@ export class NodeSDK { tracerProviderConfig, spanProcessor, configuration.contextManager, - configuration.httpTextPropagator + configuration.textMapPropagator ); } @@ -110,13 +110,13 @@ export class NodeSDK { tracerConfig: NodeTracerConfig, spanProcessor: SpanProcessor, contextManager?: ContextManager, - httpTextPropagator?: HttpTextPropagator + textMapPropagator?: TextMapPropagator ) { this._tracerProviderConfig = { tracerConfig, spanProcessor, contextManager, - httpTextPropagator, + textMapPropagator, }; } @@ -157,7 +157,7 @@ export class NodeSDK { tracerProvider.addSpanProcessor(this._tracerProviderConfig.spanProcessor); tracerProvider.register({ contextManager: this._tracerProviderConfig.contextManager, - propagator: this._tracerProviderConfig.httpTextPropagator, + propagator: this._tracerProviderConfig.textMapPropagator, }); } diff --git a/packages/opentelemetry-sdk-node/src/types.ts b/packages/opentelemetry-sdk-node/src/types.ts index a093cbcfa4..4675c88b3d 100644 --- a/packages/opentelemetry-sdk-node/src/types.ts +++ b/packages/opentelemetry-sdk-node/src/types.ts @@ -21,7 +21,7 @@ export interface NodeSDKConfiguration { autoDetectResources: boolean; contextManager: ContextManager; defaultAttributes: api.Attributes; - httpTextPropagator: api.HttpTextPropagator; + textMapPropagator: api.TextMapPropagator; logger: api.Logger; logLevel: core.LogLevel; metricBatcher: metrics.Batcher; diff --git a/packages/opentelemetry-sdk-node/test/sdk.test.ts b/packages/opentelemetry-sdk-node/test/sdk.test.ts index 0cb51a898e..474adf1b81 100644 --- a/packages/opentelemetry-sdk-node/test/sdk.test.ts +++ b/packages/opentelemetry-sdk-node/test/sdk.test.ts @@ -18,7 +18,7 @@ import * as nock from 'nock'; import { context, metrics, - NoopHttpTextPropagator, + NoopTextMapPropagator, NoopMeterProvider, NoopTracerProvider, propagation, @@ -102,7 +102,7 @@ describe('Node SDK', () => { assert.ok(context['_getContextManager']() instanceof NoopContextManager); assert.ok( - propagation['_getGlobalPropagator']() instanceof NoopHttpTextPropagator + propagation['_getGlobalPropagator']() instanceof NoopTextMapPropagator ); assert.ok(trace.getTracerProvider() instanceof NoopTracerProvider); @@ -162,7 +162,7 @@ describe('Node SDK', () => { assert.ok(context['_getContextManager']() instanceof NoopContextManager); assert.ok( - propagation['_getGlobalPropagator']() instanceof NoopHttpTextPropagator + propagation['_getGlobalPropagator']() instanceof NoopTextMapPropagator ); assert.ok(trace.getTracerProvider() instanceof NoopTracerProvider); diff --git a/packages/opentelemetry-tracing/src/types.ts b/packages/opentelemetry-tracing/src/types.ts index 4e5059cea3..c90502006e 100644 --- a/packages/opentelemetry-tracing/src/types.ts +++ b/packages/opentelemetry-tracing/src/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { HttpTextPropagator, Logger, Sampler } from '@opentelemetry/api'; +import { TextMapPropagator, Logger, Sampler } from '@opentelemetry/api'; import { LogLevel, IdGenerator } from '@opentelemetry/core'; import { ContextManager } from '@opentelemetry/context-base'; @@ -60,7 +60,7 @@ export interface TracerConfig { */ export interface SDKRegistrationConfig { /** Propagator to register as the global propagator */ - propagator?: HttpTextPropagator | null; + propagator?: TextMapPropagator | null; /** Context manager to register as the global context manager */ contextManager?: ContextManager | null; diff --git a/packages/opentelemetry-web/test/registration.test.ts b/packages/opentelemetry-web/test/registration.test.ts index 2639072bf4..4623a6c7ad 100644 --- a/packages/opentelemetry-web/test/registration.test.ts +++ b/packages/opentelemetry-web/test/registration.test.ts @@ -16,7 +16,7 @@ import { context, - NoopHttpTextPropagator, + NoopTextMapPropagator, propagation, trace, } from '@opentelemetry/api'; @@ -47,7 +47,7 @@ describe('API registration', () => { const tracerProvider = new WebTracerProvider(); const contextManager = new NoopContextManager(); - const propagator = new NoopHttpTextPropagator(); + const propagator = new NoopTextMapPropagator(); tracerProvider.register({ contextManager, @@ -81,7 +81,7 @@ describe('API registration', () => { }); assert.ok( - propagation['_getGlobalPropagator']() instanceof NoopHttpTextPropagator + propagation['_getGlobalPropagator']() instanceof NoopTextMapPropagator ); assert.ok(context['_getContextManager']() instanceof StackContextManager);