From 9670c3c35ad17362b38e0da42b17cf7604196eb3 Mon Sep 17 00:00:00 2001 From: Bartlomiej Obecny Date: Thu, 22 Apr 2021 22:12:58 +0200 Subject: [PATCH 1/5] chore: renaming jaeger http trace propagator to jaeger propagator --- .../opentelemetry-propagator-jaeger/README.md | 6 +- ...TracePropagator.ts => JaegerPropagator.ts} | 2 +- .../src/index.ts | 2 +- ...gator.test.ts => JaegerPropagator.test.ts} | 64 ++++++------------- 4 files changed, 24 insertions(+), 50 deletions(-) rename packages/opentelemetry-propagator-jaeger/src/{JaegerHttpTracePropagator.ts => JaegerPropagator.ts} (97%) rename packages/opentelemetry-propagator-jaeger/test/{JaegerHttpTracePropagator.test.ts => JaegerPropagator.test.ts} (79%) diff --git a/packages/opentelemetry-propagator-jaeger/README.md b/packages/opentelemetry-propagator-jaeger/README.md index 4990714616a..3bcfecfb34c 100644 --- a/packages/opentelemetry-propagator-jaeger/README.md +++ b/packages/opentelemetry-propagator-jaeger/README.md @@ -27,12 +27,12 @@ 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() + // Use Jaeger Propagator + 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 2afa35113f2..c631f5b81dc 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 c5c818be952..214953bd04a 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 21f81bf10b8..e5a6f82d85c 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 From 7dde139e5f18a65332f94441d6179f5b5aafe8b5 Mon Sep 17 00:00:00 2001 From: Bartlomiej Obecny Date: Thu, 22 Apr 2021 23:27:40 +0200 Subject: [PATCH 2/5] chore: missing renaming --- packages/opentelemetry-node/src/NodeTracerProvider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/opentelemetry-node/src/NodeTracerProvider.ts b/packages/opentelemetry-node/src/NodeTracerProvider.ts index dd256689a55..e2f5f5fba09 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 = {}) { From 639902c0b629f47492cbcaf8f8bf5777f67f417d Mon Sep 17 00:00:00 2001 From: Bartlomiej Obecny Date: Thu, 22 Apr 2021 23:29:19 +0200 Subject: [PATCH 3/5] chore: updating readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3e29e68cf46..a41b95a807c 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,8 @@ To request automatic tracing support for a module not on this list, please [file ### 0.18.x to 0.19.0 +- `JaegerHttpTracePropagator` renamed to `JaegerPropagator` + - 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. - All plugins have been removed in favor of instrumentations. From d4d6bcf15c66590276ed091fedc39a6b63c0cf98 Mon Sep 17 00:00:00 2001 From: Bartlomiej Obecny Date: Fri, 23 Apr 2021 19:09:56 +0200 Subject: [PATCH 4/5] chore: readme --- README.md | 4 +++- packages/opentelemetry-propagator-jaeger/README.md | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a41b95a807c..f6e3fc7bf0d 100644 --- a/README.md +++ b/README.md @@ -245,10 +245,12 @@ To request automatic tracing support for a module not on this list, please [file ## Upgrade guidelines -### 0.18.x to 0.19.0 +### 0.19.x to x - `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. - All plugins have been removed in favor of instrumentations. diff --git a/packages/opentelemetry-propagator-jaeger/README.md b/packages/opentelemetry-propagator-jaeger/README.md index 3bcfecfb34c..836c3ab743f 100644 --- a/packages/opentelemetry-propagator-jaeger/README.md +++ b/packages/opentelemetry-propagator-jaeger/README.md @@ -31,7 +31,6 @@ const { JaegerPropagator } = require('@opentelemetry/propagator-jaeger'); const provider = new NodeTracerProvider(); provider.register({ - // Use Jaeger Propagator propagator: new JaegerPropagator() }); ``` From 79234f762932e6469903d77436640f640f840c9b Mon Sep 17 00:00:00 2001 From: Bartlomiej Obecny Date: Tue, 4 May 2021 11:14:19 +0200 Subject: [PATCH 5/5] chore: fixes after merge --- .../test/Shim.test.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts index 9189b3dd42d..47d197c877c 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()