diff --git a/README.md b/README.md index e930094bb0..8164207055 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,8 @@ To request automatic tracing support for a module not on this list, please [file - `HttpTraceContext` renamed to `HttpTraceContextPropagator` +- `JaegerHttpTracePropagator` renamed to `JaegerPropagator` + ### 0.18.x to 0.19.0 - API is now a peer dependency. This means that users will need to include `@opentelemetry/api` as a dependency of their project in order to use the SDK. NPM version 7+ (Node 15+) should do this automatically. diff --git a/packages/opentelemetry-node/src/NodeTracerProvider.ts b/packages/opentelemetry-node/src/NodeTracerProvider.ts index dd256689a5..e2f5f5fba0 100644 --- a/packages/opentelemetry-node/src/NodeTracerProvider.ts +++ b/packages/opentelemetry-node/src/NodeTracerProvider.ts @@ -26,7 +26,7 @@ import { } from '@opentelemetry/tracing'; import * as semver from 'semver'; import { NodeTracerConfig } from './config'; -import { JaegerHttpTracePropagator } from '@opentelemetry/propagator-jaeger'; +import { JaegerPropagator } from '@opentelemetry/propagator-jaeger'; /** * Register this TracerProvider for use with the OpenTelemetry API. @@ -49,7 +49,7 @@ export class NodeTracerProvider extends BasicTracerProvider { 'b3multi', () => new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }), ], - ['jaeger', () => new JaegerHttpTracePropagator()], + ['jaeger', () => new JaegerPropagator()], ]); constructor(config: NodeTracerConfig = {}) { diff --git a/packages/opentelemetry-propagator-jaeger/README.md b/packages/opentelemetry-propagator-jaeger/README.md index 4990714616..836c3ab743 100644 --- a/packages/opentelemetry-propagator-jaeger/README.md +++ b/packages/opentelemetry-propagator-jaeger/README.md @@ -27,12 +27,11 @@ Example of usage: ```javascript const { NodeTracerProvider } = require('@opentelemetry/node'); -const { JaegerHttpTracePropagator } = require('@opentelemetry/propagator-jaeger'); +const { JaegerPropagator } = require('@opentelemetry/propagator-jaeger'); const provider = new NodeTracerProvider(); provider.register({ - // Use Jaeger propagator - propagator: new JaegerHttpTracePropagator() + propagator: new JaegerPropagator() }); ``` diff --git a/packages/opentelemetry-propagator-jaeger/src/JaegerHttpTracePropagator.ts b/packages/opentelemetry-propagator-jaeger/src/JaegerPropagator.ts similarity index 97% rename from packages/opentelemetry-propagator-jaeger/src/JaegerHttpTracePropagator.ts rename to packages/opentelemetry-propagator-jaeger/src/JaegerPropagator.ts index 2afa35113f..c631f5b81d 100644 --- a/packages/opentelemetry-propagator-jaeger/src/JaegerHttpTracePropagator.ts +++ b/packages/opentelemetry-propagator-jaeger/src/JaegerPropagator.ts @@ -43,7 +43,7 @@ export const UBER_TRACE_ID_HEADER = 'uber-trace-id'; * One byte bitmap, as two hex digits. * Inspired by jaeger-client-node project. */ -export class JaegerHttpTracePropagator implements TextMapPropagator { +export class JaegerPropagator implements TextMapPropagator { private readonly _jaegerTraceHeader: string; /** diff --git a/packages/opentelemetry-propagator-jaeger/src/index.ts b/packages/opentelemetry-propagator-jaeger/src/index.ts index c5c818be95..214953bd04 100644 --- a/packages/opentelemetry-propagator-jaeger/src/index.ts +++ b/packages/opentelemetry-propagator-jaeger/src/index.ts @@ -14,4 +14,4 @@ * limitations under the License. */ -export * from './JaegerHttpTracePropagator'; +export * from './JaegerPropagator'; diff --git a/packages/opentelemetry-propagator-jaeger/test/JaegerHttpTracePropagator.test.ts b/packages/opentelemetry-propagator-jaeger/test/JaegerPropagator.test.ts similarity index 79% rename from packages/opentelemetry-propagator-jaeger/test/JaegerHttpTracePropagator.test.ts rename to packages/opentelemetry-propagator-jaeger/test/JaegerPropagator.test.ts index 21f81bf10b..e5a6f82d85 100644 --- a/packages/opentelemetry-propagator-jaeger/test/JaegerHttpTracePropagator.test.ts +++ b/packages/opentelemetry-propagator-jaeger/test/JaegerPropagator.test.ts @@ -27,16 +27,14 @@ import { } from '@opentelemetry/api'; import * as assert from 'assert'; import { - JaegerHttpTracePropagator, + JaegerPropagator, UBER_TRACE_ID_HEADER, -} from '../src/JaegerHttpTracePropagator'; +} from '../src/JaegerPropagator'; -describe('JaegerHttpTracePropagator', () => { - const jaegerHttpTracePropagator = new JaegerHttpTracePropagator(); +describe('JaegerPropagator', () => { + const jaegerPropagator = new JaegerPropagator(); const customHeader = 'new-header'; - const customJaegerHttpTracePropagator = new JaegerHttpTracePropagator( - customHeader - ); + const customJaegerPropagator = new JaegerPropagator(customHeader); let carrier: { [key: string]: unknown }; beforeEach(() => { @@ -51,7 +49,7 @@ describe('JaegerHttpTracePropagator', () => { traceFlags: TraceFlags.SAMPLED, }; - jaegerHttpTracePropagator.inject( + jaegerPropagator.inject( setSpanContext(ROOT_CONTEXT, spanContext), carrier, defaultTextMapSetter @@ -69,7 +67,7 @@ describe('JaegerHttpTracePropagator', () => { traceFlags: TraceFlags.SAMPLED, }; - customJaegerHttpTracePropagator.inject( + customJaegerPropagator.inject( setSpanContext(ROOT_CONTEXT, spanContext), carrier, defaultTextMapSetter @@ -87,7 +85,7 @@ describe('JaegerHttpTracePropagator', () => { traceFlags: TraceFlags.SAMPLED, }; - jaegerHttpTracePropagator.inject( + jaegerPropagator.inject( suppressInstrumentation(setSpanContext(ROOT_CONTEXT, spanContext)), carrier, defaultTextMapSetter @@ -101,11 +99,7 @@ describe('JaegerHttpTracePropagator', () => { carrier[UBER_TRACE_ID_HEADER] = 'd4cda95b652f4a1592b449d5929fda1b:6e0c63257de34c92:0:01'; const extractedSpanContext = getSpanContext( - jaegerHttpTracePropagator.extract( - ROOT_CONTEXT, - carrier, - defaultTextMapGetter - ) + jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) ); assert.deepStrictEqual(extractedSpanContext, { @@ -120,11 +114,7 @@ describe('JaegerHttpTracePropagator', () => { carrier[UBER_TRACE_ID_HEADER] = '9c41e35aeb6d1272:45fd2a9709dadcf1:a13699e3fb724f40:1'; const extractedSpanContext = getSpanContext( - jaegerHttpTracePropagator.extract( - ROOT_CONTEXT, - carrier, - defaultTextMapGetter - ) + jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) ); assert.deepStrictEqual(extractedSpanContext, { @@ -139,11 +129,7 @@ describe('JaegerHttpTracePropagator', () => { carrier[UBER_TRACE_ID_HEADER] = 'ac1f3dc3c2c0b06e%3A5ac292c4a11a163e%3Ac086aaa825821068%3A1'; const extractedSpanContext = getSpanContext( - jaegerHttpTracePropagator.extract( - ROOT_CONTEXT, - carrier, - defaultTextMapGetter - ) + jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) ); assert.deepStrictEqual(extractedSpanContext, { @@ -158,7 +144,7 @@ describe('JaegerHttpTracePropagator', () => { carrier[customHeader] = 'd4cda95b652f4a1592b449d5929fda1b:6e0c63257de34c92:0:01'; const extractedSpanContext = getSpanContext( - customJaegerHttpTracePropagator.extract( + customJaegerPropagator.extract( ROOT_CONTEXT, carrier, defaultTextMapGetter @@ -176,11 +162,7 @@ describe('JaegerHttpTracePropagator', () => { it('returns undefined if UBER_TRACE_ID_HEADER header is missing', () => { assert.deepStrictEqual( getSpanContext( - jaegerHttpTracePropagator.extract( - ROOT_CONTEXT, - carrier, - defaultTextMapGetter - ) + jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) ), undefined ); @@ -190,11 +172,7 @@ describe('JaegerHttpTracePropagator', () => { carrier[UBER_TRACE_ID_HEADER] = 'invalid!'; assert.deepStrictEqual( getSpanContext( - jaegerHttpTracePropagator.extract( - ROOT_CONTEXT, - carrier, - defaultTextMapGetter - ) + jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) ), undefined ); @@ -203,29 +181,25 @@ describe('JaegerHttpTracePropagator', () => { describe('.fields()', () => { it('returns the default header if not customized', () => { - assert.deepStrictEqual(jaegerHttpTracePropagator.fields(), [ - 'uber-trace-id', - ]); + assert.deepStrictEqual(jaegerPropagator.fields(), ['uber-trace-id']); }); it('returns the customized header if customized', () => { - assert.deepStrictEqual(customJaegerHttpTracePropagator.fields(), [ - customHeader, - ]); + assert.deepStrictEqual(customJaegerPropagator.fields(), [customHeader]); }); }); it('should fail gracefully on bad responses from getter', () => { - const ctx1 = jaegerHttpTracePropagator.extract( + const ctx1 = jaegerPropagator.extract( ROOT_CONTEXT, carrier, makeGetter(1) // not a number ); - const ctx2 = jaegerHttpTracePropagator.extract( + const ctx2 = jaegerPropagator.extract( ROOT_CONTEXT, carrier, makeGetter([]) // empty array ); - const ctx3 = jaegerHttpTracePropagator.extract( + const ctx3 = jaegerPropagator.extract( ROOT_CONTEXT, carrier, makeGetter(undefined) // missing value diff --git a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts index 9189b3dd42..47d197c877 100644 --- a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts +++ b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts @@ -36,7 +36,7 @@ import { } from '@opentelemetry/api'; import { performance } from 'perf_hooks'; import { B3Propagator } from '@opentelemetry/propagator-b3'; -import { JaegerHttpTracePropagator } from '@opentelemetry/propagator-jaeger'; +import { JaegerPropagator } from '@opentelemetry/propagator-jaeger'; describe('OpenTracing Shim', () => { const compositePropagator = new CompositePropagator({ @@ -129,13 +129,13 @@ describe('OpenTracing Shim', () => { }); describe('propagation using configured propagators', () => { - const jaegerHttpTracePropagator = new JaegerHttpTracePropagator(); + const jaegerPropagator = new JaegerPropagator(); const b3Propagator = new B3Propagator(); before(() => { const provider = new BasicTracerProvider(); shimTracer = new TracerShim(provider.getTracer('default'), { textMapPropagator: b3Propagator, - httpHeadersPropagator: jaegerHttpTracePropagator, + httpHeadersPropagator: jaegerPropagator, }); opentracing.initGlobalTracer(shimTracer); }); @@ -149,11 +149,7 @@ describe('OpenTracing Shim', () => { const carrier: { [key: string]: unknown } = {}; shimTracer.inject(context, opentracing.FORMAT_HTTP_HEADERS, carrier); const extractedContext = getSpanContext( - jaegerHttpTracePropagator.extract( - ROOT_CONTEXT, - carrier, - defaultTextMapGetter - ) + jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) ); assert.ok(extractedContext !== null); assert.strictEqual(extractedContext?.traceId, context.toTraceId()); @@ -162,7 +158,7 @@ describe('OpenTracing Shim', () => { it('extracts HTTP carriers', () => { const carrier: { [key: string]: unknown } = {}; - jaegerHttpTracePropagator.inject( + jaegerPropagator.inject( setSpanContext( ROOT_CONTEXT, (context as SpanContextShim).getSpanContext()