From 768c791a9a00c2d433bf9ffe9f0e651c94332e8d Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 19 Aug 2020 09:12:11 -0400 Subject: [PATCH 1/5] feat: tracers provided by the API become useable when provider registered --- packages/opentelemetry-api/package.json | 2 + packages/opentelemetry-api/src/api/trace.ts | 10 +- packages/opentelemetry-api/src/index.ts | 2 + .../src/trace/ProxyTracer.ts | 71 ++++++++++ .../src/trace/ProxyTracerProvider.ts | 52 +++++++ .../proxy-tracer.test.ts | 129 ++++++++++++++++++ 6 files changed, 264 insertions(+), 2 deletions(-) create mode 100644 packages/opentelemetry-api/src/trace/ProxyTracer.ts create mode 100644 packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts create mode 100644 packages/opentelemetry-api/test/proxy-implementations/proxy-tracer.test.ts diff --git a/packages/opentelemetry-api/package.json b/packages/opentelemetry-api/package.json index f3f5761e5c..22edcdd642 100644 --- a/packages/opentelemetry-api/package.json +++ b/packages/opentelemetry-api/package.json @@ -57,6 +57,7 @@ "devDependencies": { "@types/mocha": "8.0.2", "@types/node": "14.0.27", + "@types/sinon": "4.3.1", "@types/webpack-env": "1.15.2", "codecov": "3.7.2", "gts": "2.0.2", @@ -70,6 +71,7 @@ "linkinator": "2.1.1", "mocha": "7.2.0", "nyc": "15.1.0", + "sinon": "9.0.3", "ts-loader": "8.0.2", "ts-mocha": "7.0.0", "typedoc": "0.18.0", diff --git a/packages/opentelemetry-api/src/api/trace.ts b/packages/opentelemetry-api/src/api/trace.ts index 0ba58af77a..2cae47358f 100644 --- a/packages/opentelemetry-api/src/api/trace.ts +++ b/packages/opentelemetry-api/src/api/trace.ts @@ -15,6 +15,7 @@ */ import { NOOP_TRACER_PROVIDER } from '../trace/NoopTracerProvider'; +import { ProxyTracerProvider } from '../trace/ProxyTracerProvider'; import { Tracer } from '../trace/tracer'; import { TracerProvider } from '../trace/tracer_provider'; import { @@ -30,6 +31,8 @@ import { export class TraceAPI { private static _instance?: TraceAPI; + private _tracerProviderProxy = new ProxyTracerProvider(); + /** Empty private constructor prevents end users from constructing a new instance of the API */ private constructor() {} @@ -51,9 +54,11 @@ export class TraceAPI { return this.getTracerProvider(); } + this._tracerProviderProxy.setDelegate(provider); + _global[GLOBAL_TRACE_API_KEY] = makeGetter( API_BACKWARDS_COMPATIBILITY_VERSION, - provider, + this._tracerProviderProxy, NOOP_TRACER_PROVIDER ); @@ -66,7 +71,7 @@ export class TraceAPI { public getTracerProvider(): TracerProvider { return ( _global[GLOBAL_TRACE_API_KEY]?.(API_BACKWARDS_COMPATIBILITY_VERSION) ?? - NOOP_TRACER_PROVIDER + this._tracerProviderProxy ); } @@ -80,5 +85,6 @@ export class TraceAPI { /** Remove the global tracer provider */ public disable() { delete _global[GLOBAL_TRACE_API_KEY]; + this._tracerProviderProxy = new ProxyTracerProvider(); } } diff --git a/packages/opentelemetry-api/src/index.ts b/packages/opentelemetry-api/src/index.ts index f9bcf40664..f2e077cf41 100644 --- a/packages/opentelemetry-api/src/index.ts +++ b/packages/opentelemetry-api/src/index.ts @@ -39,6 +39,8 @@ export * from './trace/link'; export * from './trace/NoopSpan'; export * from './trace/NoopTracer'; export * from './trace/NoopTracerProvider'; +export * from './trace/ProxyTracer'; +export * from './trace/ProxyTracerProvider'; export * from './trace/Sampler'; export * from './trace/SamplingResult'; export * from './trace/span_context'; diff --git a/packages/opentelemetry-api/src/trace/ProxyTracer.ts b/packages/opentelemetry-api/src/trace/ProxyTracer.ts new file mode 100644 index 0000000000..e2216eed5e --- /dev/null +++ b/packages/opentelemetry-api/src/trace/ProxyTracer.ts @@ -0,0 +1,71 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Span, SpanOptions, Tracer } from '..'; +import { NOOP_TRACER } from './NoopTracer'; +import { ProxyTracerProvider } from './ProxyTracerProvider'; + +/** + * Proxy tracer provided by the proxy tracer provider + */ +export class ProxyTracer implements Tracer { + // When a real implementation is provided, this will be it + private _delegate?: Tracer; + + constructor( + private _provider: ProxyTracerProvider, + public readonly name: string, + public readonly version?: string + ) {} + + getCurrentSpan(): Span | undefined { + return this._getTracer().getCurrentSpan(); + } + + startSpan(name: string, options?: SpanOptions): Span { + return this._getTracer().startSpan(name, options); + } + + withSpan ReturnType>( + span: Span, + fn: T + ): ReturnType { + return this._getTracer().withSpan(span, fn); + } + + bind(target: T, span?: Span): T { + return this._getTracer().bind(target, span); + } + + /** + * Try to get a tracer from the proxy tracer provider. + * If the proxy tracer provider has no delegate, return a noop tracer. + */ + private _getTracer() { + if (this._delegate) { + return this._delegate; + } + + const tracer = this._provider.getDelegateTracer(this.name, this.version); + + if (!tracer) { + return NOOP_TRACER; + } + + this._delegate = tracer; + return this._delegate; + } +} diff --git a/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts b/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts new file mode 100644 index 0000000000..dc718aff4a --- /dev/null +++ b/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts @@ -0,0 +1,52 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Tracer } from './tracer'; +import { TracerProvider } from './tracer_provider'; +import { ProxyTracer } from './ProxyTracer'; + +/** + * Tracer provider which provides {@link ProxyTracer}s. + * + * Before a delegate is set, tracers provided are NoOp. + * When a delegate is set, traces are provided from the delegate. + * When a delegate is set after tracers have already been provided, + * all tracers already provided will use the provided delegate implementation. + */ +export class ProxyTracerProvider implements TracerProvider { + private _delegate?: TracerProvider; + + /** + * Get a {@link ProxyTracer} + */ + getTracer(name: string, version?: string): Tracer { + return ( + this._delegate?.getTracer(name, version) ?? + new ProxyTracer(this, name, version) + ); + } + + /** + * Set the delegate tracer provider + */ + setDelegate(delegate: TracerProvider) { + this._delegate = delegate; + } + + getDelegateTracer(name: string, version?: string): Tracer | undefined { + return this._delegate?.getTracer(name, version); + } +} diff --git a/packages/opentelemetry-api/test/proxy-implementations/proxy-tracer.test.ts b/packages/opentelemetry-api/test/proxy-implementations/proxy-tracer.test.ts new file mode 100644 index 0000000000..7a110cbfa3 --- /dev/null +++ b/packages/opentelemetry-api/test/proxy-implementations/proxy-tracer.test.ts @@ -0,0 +1,129 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import { + NoopSpan, + NOOP_SPAN, + ProxyTracerProvider, + SpanKind, + TracerProvider, + ProxyTracer, + Tracer, + Span, + NoopTracer, +} from '../../src'; + +describe('ProxyTracer', () => { + let provider: ProxyTracerProvider; + + beforeEach(() => { + provider = new ProxyTracerProvider(); + }); + + describe('when no delegate is set', () => { + it('should return proxy tracers', () => { + const tracer = provider.getTracer('test'); + + assert.ok(tracer instanceof ProxyTracer); + }); + + it('startSpan should return Noop Spans', () => { + const tracer = provider.getTracer('test'); + + assert.deepStrictEqual(tracer.startSpan('span-name'), NOOP_SPAN); + assert.deepStrictEqual( + tracer.startSpan('span-name1', { kind: SpanKind.CLIENT }), + NOOP_SPAN + ); + assert.deepStrictEqual( + tracer.startSpan('span-name2', { + kind: SpanKind.CLIENT, + }), + NOOP_SPAN + ); + + assert.deepStrictEqual(tracer.getCurrentSpan(), NOOP_SPAN); + }); + }); + + describe('when delegate is set before getTracer', () => { + let delegate: TracerProvider; + const sandbox = sinon.createSandbox(); + let getTracerStub: sinon.SinonStub; + + beforeEach(() => { + getTracerStub = sandbox.stub().returns(new NoopTracer()); + delegate = { + getTracer: getTracerStub, + }; + provider.setDelegate(delegate); + }); + + afterEach(() => { + sandbox.restore(); + }); + + it('should return tracers directly from the delegate', () => { + const tracer = provider.getTracer('test', 'v0'); + + sandbox.assert.calledOnce(getTracerStub); + assert.strictEqual(getTracerStub.firstCall.returnValue, tracer); + assert.deepEqual(getTracerStub.firstCall.args, ['test', 'v0']); + }); + }); + + describe('when delegate is set after getTracer', () => { + let tracer: Tracer; + let delegate: TracerProvider; + let delegateSpan: Span; + let delegateTracer: Tracer; + + beforeEach(() => { + delegateSpan = new NoopSpan(); + delegateTracer = { + bind(target) { + return target; + }, + getCurrentSpan() { + return delegateSpan; + }, + startSpan() { + return delegateSpan; + }, + withSpan(span, fn) { + return fn(); + }, + }; + + tracer = provider.getTracer('test'); + + delegate = { + getTracer() { + return delegateTracer; + }, + }; + provider.setDelegate(delegate); + }); + + it('should create spans using the delegate tracer', () => { + const span = tracer.startSpan('test'); + + assert.strictEqual(span, delegateSpan); + }); + }); +}); From 158628eb5ab819a92525ee2a9429160a8b7e49c1 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 26 Aug 2020 10:38:21 -0400 Subject: [PATCH 2/5] chore: review comments --- packages/opentelemetry-api/src/api/trace.ts | 10 +++++----- .../opentelemetry-api/src/trace/ProxyTracerProvider.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/opentelemetry-api/src/api/trace.ts b/packages/opentelemetry-api/src/api/trace.ts index 2cae47358f..cfb4dad85f 100644 --- a/packages/opentelemetry-api/src/api/trace.ts +++ b/packages/opentelemetry-api/src/api/trace.ts @@ -31,7 +31,7 @@ import { export class TraceAPI { private static _instance?: TraceAPI; - private _tracerProviderProxy = new ProxyTracerProvider(); + private _proxyTracerProvider = new ProxyTracerProvider(); /** Empty private constructor prevents end users from constructing a new instance of the API */ private constructor() {} @@ -54,11 +54,11 @@ export class TraceAPI { return this.getTracerProvider(); } - this._tracerProviderProxy.setDelegate(provider); + this._proxyTracerProvider.setDelegate(provider); _global[GLOBAL_TRACE_API_KEY] = makeGetter( API_BACKWARDS_COMPATIBILITY_VERSION, - this._tracerProviderProxy, + this._proxyTracerProvider, NOOP_TRACER_PROVIDER ); @@ -71,7 +71,7 @@ export class TraceAPI { public getTracerProvider(): TracerProvider { return ( _global[GLOBAL_TRACE_API_KEY]?.(API_BACKWARDS_COMPATIBILITY_VERSION) ?? - this._tracerProviderProxy + this._proxyTracerProvider ); } @@ -85,6 +85,6 @@ export class TraceAPI { /** Remove the global tracer provider */ public disable() { delete _global[GLOBAL_TRACE_API_KEY]; - this._tracerProviderProxy = new ProxyTracerProvider(); + this._proxyTracerProvider = new ProxyTracerProvider(); } } diff --git a/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts b/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts index dc718aff4a..b46adf8b07 100644 --- a/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts +++ b/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts @@ -34,7 +34,7 @@ export class ProxyTracerProvider implements TracerProvider { */ getTracer(name: string, version?: string): Tracer { return ( - this._delegate?.getTracer(name, version) ?? + this.getDelegateTracer(name, version) ?? new ProxyTracer(this, name, version) ); } From 9dfbdca7c3462d0292a1edfe2bacc4bfdc3ebd45 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 27 Aug 2020 09:10:52 -0400 Subject: [PATCH 3/5] chore: fix build --- .../src/trace/ProxyTracerProvider.ts | 5 +++++ .../test/registration.test.ts | 20 +++++++++++++++---- .../opentelemetry-sdk-node/test/sdk.test.ts | 19 ++++++++++++++---- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts b/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts index b46adf8b07..d8a3ced2ec 100644 --- a/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts +++ b/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts @@ -17,6 +17,7 @@ import { Tracer } from './tracer'; import { TracerProvider } from './tracer_provider'; import { ProxyTracer } from './ProxyTracer'; +import { NOOP_TRACER_PROVIDER } from './NoopTracerProvider'; /** * Tracer provider which provides {@link ProxyTracer}s. @@ -39,6 +40,10 @@ export class ProxyTracerProvider implements TracerProvider { ); } + getDelegate(): TracerProvider { + return this._delegate ?? NOOP_TRACER_PROVIDER + } + /** * Set the delegate tracer provider */ diff --git a/packages/opentelemetry-node/test/registration.test.ts b/packages/opentelemetry-node/test/registration.test.ts index 2e031fd6b1..aef79760f5 100644 --- a/packages/opentelemetry-node/test/registration.test.ts +++ b/packages/opentelemetry-node/test/registration.test.ts @@ -19,6 +19,7 @@ import { NoopTextMapPropagator, propagation, trace, + ProxyTracerProvider, } from '@opentelemetry/api'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { NoopContextManager } from '@opentelemetry/context-base'; @@ -43,7 +44,10 @@ describe('API registration', () => { assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator ); - assert.ok(trace.getTracerProvider() === tracerProvider); + const apiTracerProvider = trace.getTracerProvider(); + + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() === tracerProvider); }); it('should register configured implementations', () => { @@ -60,7 +64,9 @@ describe('API registration', () => { assert.ok(context['_getContextManager']() === contextManager); assert.ok(propagation['_getGlobalPropagator']() === propagator); - assert.ok(trace.getTracerProvider() === tracerProvider); + const apiTracerProvider = trace.getTracerProvider(); + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() === tracerProvider); }); it('should skip null context manager', () => { @@ -74,7 +80,10 @@ describe('API registration', () => { assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator ); - assert.ok(trace.getTracerProvider() === tracerProvider); + + const apiTracerProvider = trace.getTracerProvider(); + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() === tracerProvider); }); it('should skip null propagator', () => { @@ -90,6 +99,9 @@ describe('API registration', () => { assert.ok( context['_getContextManager']() instanceof AsyncHooksContextManager ); - assert.ok(trace.getTracerProvider() === tracerProvider); + + const apiTracerProvider = trace.getTracerProvider(); + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() === tracerProvider); }); }); diff --git a/packages/opentelemetry-sdk-node/test/sdk.test.ts b/packages/opentelemetry-sdk-node/test/sdk.test.ts index 474adf1b81..91456548b8 100644 --- a/packages/opentelemetry-sdk-node/test/sdk.test.ts +++ b/packages/opentelemetry-sdk-node/test/sdk.test.ts @@ -23,6 +23,7 @@ import { NoopTracerProvider, propagation, trace, + ProxyTracerProvider, } from '@opentelemetry/api'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { NoopContextManager } from '@opentelemetry/context-base'; @@ -105,7 +106,11 @@ describe('Node SDK', () => { propagation['_getGlobalPropagator']() instanceof NoopTextMapPropagator ); - assert.ok(trace.getTracerProvider() instanceof NoopTracerProvider); + const apiTracerProvider = trace.getTracerProvider(); + console.log(apiTracerProvider) + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() instanceof NoopTracerProvider); + assert.ok(metrics.getMeterProvider() instanceof NoopMeterProvider); }); @@ -125,7 +130,9 @@ describe('Node SDK', () => { assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator ); - assert.ok(trace.getTracerProvider() instanceof NodeTracerProvider); + const apiTracerProvider = trace.getTracerProvider(); + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() instanceof NodeTracerProvider); }); it('should register a tracer provider if a span processor is provided', async () => { @@ -147,7 +154,9 @@ describe('Node SDK', () => { assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator ); - assert.ok(trace.getTracerProvider() instanceof NodeTracerProvider); + const apiTracerProvider = trace.getTracerProvider(); + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() instanceof NodeTracerProvider); }); it('should register a meter provider if an exporter is provided', async () => { @@ -165,7 +174,9 @@ describe('Node SDK', () => { propagation['_getGlobalPropagator']() instanceof NoopTextMapPropagator ); - assert.ok(trace.getTracerProvider() instanceof NoopTracerProvider); + const apiTracerProvider = trace.getTracerProvider(); + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() instanceof NoopTracerProvider); assert.ok(metrics.getMeterProvider() instanceof MeterProvider); }); From d2260aa8c9cd5001d7812481d24abd5a429b0d71 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 27 Aug 2020 09:19:05 -0400 Subject: [PATCH 4/5] chore: lint --- packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts | 2 +- packages/opentelemetry-sdk-node/test/sdk.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts b/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts index d8a3ced2ec..e124dc9506 100644 --- a/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts +++ b/packages/opentelemetry-api/src/trace/ProxyTracerProvider.ts @@ -41,7 +41,7 @@ export class ProxyTracerProvider implements TracerProvider { } getDelegate(): TracerProvider { - return this._delegate ?? NOOP_TRACER_PROVIDER + return this._delegate ?? NOOP_TRACER_PROVIDER; } /** diff --git a/packages/opentelemetry-sdk-node/test/sdk.test.ts b/packages/opentelemetry-sdk-node/test/sdk.test.ts index 91456548b8..73aeb40b53 100644 --- a/packages/opentelemetry-sdk-node/test/sdk.test.ts +++ b/packages/opentelemetry-sdk-node/test/sdk.test.ts @@ -107,7 +107,7 @@ describe('Node SDK', () => { ); const apiTracerProvider = trace.getTracerProvider(); - console.log(apiTracerProvider) + console.log(apiTracerProvider); assert.ok(apiTracerProvider instanceof ProxyTracerProvider); assert.ok(apiTracerProvider.getDelegate() instanceof NoopTracerProvider); From fdf98446534e66bc4b74faad6f9a62111f170daa Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 27 Aug 2020 09:41:53 -0400 Subject: [PATCH 5/5] chore: fix browser tests --- .../opentelemetry-web/test/registration.test.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/opentelemetry-web/test/registration.test.ts b/packages/opentelemetry-web/test/registration.test.ts index 4623a6c7ad..123b9667d1 100644 --- a/packages/opentelemetry-web/test/registration.test.ts +++ b/packages/opentelemetry-web/test/registration.test.ts @@ -19,6 +19,7 @@ import { NoopTextMapPropagator, propagation, trace, + ProxyTracerProvider, } from '@opentelemetry/api'; import { NoopContextManager } from '@opentelemetry/context-base'; import { CompositePropagator } from '@opentelemetry/core'; @@ -40,7 +41,9 @@ describe('API registration', () => { assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator ); - assert.ok(trace.getTracerProvider() === tracerProvider); + const apiTracerProvider = trace.getTracerProvider(); + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() === tracerProvider); }); it('should register configured implementations', () => { @@ -57,7 +60,9 @@ describe('API registration', () => { assert.ok(context['_getContextManager']() === contextManager); assert.ok(propagation['_getGlobalPropagator']() === propagator); - assert.ok(trace.getTracerProvider() === tracerProvider); + const apiTracerProvider = trace.getTracerProvider(); + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() === tracerProvider); }); it('should skip null context manager', () => { @@ -71,7 +76,9 @@ describe('API registration', () => { assert.ok( propagation['_getGlobalPropagator']() instanceof CompositePropagator ); - assert.ok(trace.getTracerProvider() === tracerProvider); + const apiTracerProvider = trace.getTracerProvider(); + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() === tracerProvider); }); it('should skip null propagator', () => { @@ -85,6 +92,8 @@ describe('API registration', () => { ); assert.ok(context['_getContextManager']() instanceof StackContextManager); - assert.ok(trace.getTracerProvider() === tracerProvider); + const apiTracerProvider = trace.getTracerProvider(); + assert.ok(apiTracerProvider instanceof ProxyTracerProvider); + assert.ok(apiTracerProvider.getDelegate() === tracerProvider); }); });