From 7d201d38f8f82bf3709ec1fa8b8879b4cba3b7d1 Mon Sep 17 00:00:00 2001 From: Aaron Abbott Date: Thu, 26 Aug 2021 15:56:07 +0000 Subject: [PATCH] fix!: rename HttpTraceContextPropagator to TraceContextTextMapPropagator --- benchmark/propagator.js | 4 ++-- .../validation-server.js | 4 ++-- packages/opentelemetry-core/README.md | 8 ++++---- packages/opentelemetry-core/src/index.ts | 2 +- .../src/trace/HttpTraceContextPropagator.ts | 2 +- .../test/propagation/composite.test.ts | 12 ++++++------ .../test/trace/HttpTraceContextPropagator.test.ts | 8 ++++---- .../test/helper.ts | 4 ++-- .../src/BasicTracerProvider.ts | 4 ++-- .../opentelemetry-shim-opentracing/test/Shim.test.ts | 4 ++-- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/benchmark/propagator.js b/benchmark/propagator.js index 51a8058e1f8..9c62c12cfcb 100644 --- a/benchmark/propagator.js +++ b/benchmark/propagator.js @@ -17,8 +17,8 @@ const setups = [ } }, { - name: 'HttpTraceContextPropagator', - propagator: new opentelemetry.HttpTraceContextPropagator(), + name: 'TraceContextTextMapPropagator', + propagator: new opentelemetry.TraceContextTextMapPropagator(), injectCarrier: {}, extractCarrier: { traceparent: '00-d4cda95b652f4a1592b449d5929fda1b-6e0c63257de34c92-00' diff --git a/integration-tests/propagation-validation-server/validation-server.js b/integration-tests/propagation-validation-server/validation-server.js index 1a1f8fab15e..cfca3bdbcd2 100644 --- a/integration-tests/propagation-validation-server/validation-server.js +++ b/integration-tests/propagation-validation-server/validation-server.js @@ -1,5 +1,5 @@ const axios = require("axios"); -const { HttpTraceContextPropagator } = require("@opentelemetry/core"); +const { TraceContextTextMapPropagator } = require("@opentelemetry/core"); const { BasicTracerProvider } = require("@opentelemetry/sdk-trace-base"); const { context, propagation, trace, ROOT_CONTEXT } = require("@opentelemetry/api"); const { @@ -8,7 +8,7 @@ const { const bodyParser = require("body-parser"); // set global propagator -propagation.setGlobalPropagator(new HttpTraceContextPropagator()); +propagation.setGlobalPropagator(new TraceContextTextMapPropagator()); // set global context manager context.setGlobalContextManager(new AsyncHooksContextManager()); diff --git a/packages/opentelemetry-core/README.md b/packages/opentelemetry-core/README.md index 35e96e3e59a..4243af80051 100644 --- a/packages/opentelemetry-core/README.md +++ b/packages/opentelemetry-core/README.md @@ -12,7 +12,7 @@ This package provides default implementations of the OpenTelemetry API for trace - [OpenTelemetry Core](#opentelemetry-core) - [Built-in Implementations](#built-in-implementations) - [Built-in Propagators](#built-in-propagators) - - [HttpTraceContextPropagator Propagator](#httptracecontext-propagator) + - [TraceContextTextMapPropagator Propagator](#httptracecontext-propagator) - [Composite Propagator](#composite-propagator) - [Baggage Propagator](#baggage-propagator) - [Built-in Sampler](#built-in-sampler) @@ -25,16 +25,16 @@ This package provides default implementations of the OpenTelemetry API for trace ### Built-in Propagators -#### HttpTraceContextPropagator Propagator +#### TraceContextTextMapPropagator Propagator OpenTelemetry provides a text-based approach to propagate context to remote services using the [W3C Trace Context](https://www.w3.org/TR/trace-context/) HTTP headers. ```js const api = require("@opentelemetry/api"); -const { HttpTraceContextPropagator } = require("@opentelemetry/core"); +const { TraceContextTextMapPropagator } = require("@opentelemetry/core"); /* Set Global Propagator */ -api.propagation.setGlobalPropagator(new HttpTraceContextPropagator()); +api.propagation.setGlobalPropagator(new TraceContextTextMapPropagator()); ``` #### Composite Propagator diff --git a/packages/opentelemetry-core/src/index.ts b/packages/opentelemetry-core/src/index.ts index a204b157078..a498b88f5ed 100644 --- a/packages/opentelemetry-core/src/index.ts +++ b/packages/opentelemetry-core/src/index.ts @@ -25,7 +25,7 @@ export * from './version'; export * as baggageUtils from './baggage/utils'; export * from './platform'; export * from './propagation/composite'; -export * from './trace/HttpTraceContextPropagator'; +export * from './trace/TraceContextTextMapPropagator'; export * from './trace/IdGenerator'; export * from './trace/rpc-metadata'; export * from './trace/sampler/AlwaysOffSampler'; diff --git a/packages/opentelemetry-core/src/trace/HttpTraceContextPropagator.ts b/packages/opentelemetry-core/src/trace/HttpTraceContextPropagator.ts index b41d99fbf91..9fe6f5bac6d 100644 --- a/packages/opentelemetry-core/src/trace/HttpTraceContextPropagator.ts +++ b/packages/opentelemetry-core/src/trace/HttpTraceContextPropagator.ts @@ -70,7 +70,7 @@ export function parseTraceParent(traceParent: string): SpanContext | null { * Based on the Trace Context specification: * https://www.w3.org/TR/trace-context/ */ -export class HttpTraceContextPropagator implements TextMapPropagator { +export class TraceContextTextMapPropagator implements TextMapPropagator { inject(context: Context, carrier: unknown, setter: TextMapSetter): void { const spanContext = trace.getSpanContext(context); if ( diff --git a/packages/opentelemetry-core/test/propagation/composite.test.ts b/packages/opentelemetry-core/test/propagation/composite.test.ts index 1e5b6d989a3..db20dfa848e 100644 --- a/packages/opentelemetry-core/test/propagation/composite.test.ts +++ b/packages/opentelemetry-core/test/propagation/composite.test.ts @@ -26,13 +26,13 @@ import { Context, ROOT_CONTEXT } from '@opentelemetry/api'; import * as assert from 'assert'; import { CompositePropagator, - HttpTraceContextPropagator, + TraceContextTextMapPropagator, RandomIdGenerator, } from '../../src'; import { TRACE_PARENT_HEADER, TRACE_STATE_HEADER, -} from '../../src/trace/HttpTraceContextPropagator'; +} from '../../src/trace/TraceContextTextMapPropagator'; import { TraceState } from '../../src/trace/TraceState'; class DummyPropagator implements TextMapPropagator { @@ -78,7 +78,7 @@ describe('Composite Propagator', () => { it('should inject context using all configured propagators', () => { const composite = new CompositePropagator({ - propagators: [new DummyPropagator(), new HttpTraceContextPropagator()], + propagators: [new DummyPropagator(), new TraceContextTextMapPropagator()], }); composite.inject(ctxWithSpanContext, carrier, defaultTextMapSetter); @@ -94,7 +94,7 @@ describe('Composite Propagator', () => { const composite = new CompositePropagator({ propagators: [ new ThrowingPropagator(), - new HttpTraceContextPropagator(), + new TraceContextTextMapPropagator(), ], }); composite.inject(ctxWithSpanContext, carrier, defaultTextMapSetter); @@ -119,7 +119,7 @@ describe('Composite Propagator', () => { it('should extract context using all configured propagators', () => { const composite = new CompositePropagator({ - propagators: [new DummyPropagator(), new HttpTraceContextPropagator()], + propagators: [new DummyPropagator(), new TraceContextTextMapPropagator()], }); const spanContext = trace.getSpanContext( composite.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) @@ -140,7 +140,7 @@ describe('Composite Propagator', () => { const composite = new CompositePropagator({ propagators: [ new ThrowingPropagator(), - new HttpTraceContextPropagator(), + new TraceContextTextMapPropagator(), ], }); const spanContext = trace.getSpanContext( diff --git a/packages/opentelemetry-core/test/trace/HttpTraceContextPropagator.test.ts b/packages/opentelemetry-core/test/trace/HttpTraceContextPropagator.test.ts index 0ccd526e6f8..7c37ac06ae8 100644 --- a/packages/opentelemetry-core/test/trace/HttpTraceContextPropagator.test.ts +++ b/packages/opentelemetry-core/test/trace/HttpTraceContextPropagator.test.ts @@ -25,15 +25,15 @@ import { } from '@opentelemetry/api'; import * as assert from 'assert'; import { - HttpTraceContextPropagator, + TraceContextTextMapPropagator, TRACE_PARENT_HEADER, TRACE_STATE_HEADER, -} from '../../src/trace/HttpTraceContextPropagator'; +} from '../../src/trace/TraceContextTextMapPropagator'; import { suppressTracing } from '../../src/trace/suppress-tracing'; import { TraceState } from '../../src/trace/TraceState'; -describe('HttpTraceContextPropagator', () => { - const httpTraceContext = new HttpTraceContextPropagator(); +describe('TraceContextTextMapPropagator', () => { + const httpTraceContext = new TraceContextTextMapPropagator(); let carrier: { [key: string]: unknown }; beforeEach(() => { diff --git a/packages/opentelemetry-instrumentation-grpc/test/helper.ts b/packages/opentelemetry-instrumentation-grpc/test/helper.ts index 559b9acf062..2934e627b98 100644 --- a/packages/opentelemetry-instrumentation-grpc/test/helper.ts +++ b/packages/opentelemetry-instrumentation-grpc/test/helper.ts @@ -19,7 +19,7 @@ import { SpanKind, propagation, trace, } from '@opentelemetry/api'; -import { HttpTraceContextPropagator } from '@opentelemetry/core'; +import { TraceContextTextMapPropagator } from '@opentelemetry/core'; import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { ContextManager } from '@opentelemetry/api'; @@ -386,7 +386,7 @@ export const runTests = ( let contextManager: ContextManager; before(() => { - propagation.setGlobalPropagator(new HttpTraceContextPropagator()); + propagation.setGlobalPropagator(new TraceContextTextMapPropagator()); }); beforeEach(() => { diff --git a/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts b/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts index d02d92bccb7..73f965826b8 100644 --- a/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts +++ b/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts @@ -25,7 +25,7 @@ import { import { CompositePropagator, HttpBaggagePropagator, - HttpTraceContextPropagator, + TraceContextTextMapPropagator, getEnv, } from '@opentelemetry/core'; import { Resource } from '@opentelemetry/resources'; @@ -57,7 +57,7 @@ export class BasicTracerProvider implements TracerProvider { string, PROPAGATOR_FACTORY >([ - ['tracecontext', () => new HttpTraceContextPropagator()], + ['tracecontext', () => new TraceContextTextMapPropagator()], ['baggage', () => new HttpBaggagePropagator()], ]); diff --git a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts index 41035a3e913..ac7b9fe8046 100644 --- a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts +++ b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts @@ -21,7 +21,7 @@ import { SpanContextShim, SpanShim, TracerShim } from '../src/shim'; import { CompositePropagator, HttpBaggagePropagator, - HttpTraceContextPropagator, + TraceContextTextMapPropagator, timeInputToHrTime, } from '@opentelemetry/core'; import { @@ -41,7 +41,7 @@ import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; describe('OpenTracing Shim', () => { const compositePropagator = new CompositePropagator({ propagators: [ - new HttpTraceContextPropagator(), + new TraceContextTextMapPropagator(), new HttpBaggagePropagator(), ], });