Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! feat(sdk-trace-base)!: drop ability to instantiate propagators…
… beyond defaults
  • Loading branch information
pichlermarc committed Jan 21, 2025
commit 4072001d19fe6ab3b61917be2660e0f319de2a9c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
TextMapGetter,
propagation,
diag,
ContextManager,
} from '@opentelemetry/api';
import { CompositePropagator } from '@opentelemetry/core';
import { TraceState } from '@opentelemetry/core';
Expand Down Expand Up @@ -59,6 +60,7 @@ class DummyPropagator implements TextMapPropagator {
describe('BasicTracerProvider', () => {
let envSource: Record<string, any>;
let setGlobalPropagatorStub: sinon.SinonSpy<[TextMapPropagator], boolean>;
let setGlobalContextManagerStub: sinon.SinonSpy<[ContextManager], boolean>;

if (global.process?.versions?.node === undefined) {
envSource = globalThis as unknown as Record<string, any>;
Expand All @@ -70,6 +72,7 @@ describe('BasicTracerProvider', () => {
// to avoid actually registering the TraceProvider and leaking env to other tests
sinon.stub(trace, 'setGlobalTracerProvider');
setGlobalPropagatorStub = sinon.spy(propagation, 'setGlobalPropagator');
setGlobalContextManagerStub = sinon.spy(context, 'setGlobalContextManager');

context.disable();
});
Expand Down Expand Up @@ -415,6 +418,34 @@ describe('BasicTracerProvider', () => {
]);
});
});
describe('contextManager', () => {
it('should not be set if not provided', () => {
const provider = new BasicTracerProvider();
provider.register();

sinon.assert.notCalled(setGlobalContextManagerStub);
});

it('should be set if provided', () => {
const provider = new BasicTracerProvider();
const mockContextManager: ContextManager = {
active: sinon.stub(),
bind: sinon.stub(),
disable: sinon.stub(),
enable: sinon.stub(),
with: sinon.stub(),
};

provider.register({
contextManager: mockContextManager,
});

sinon.assert.calledOnceWithExactly(
setGlobalContextManagerStub,
mockContextManager
);
});
});
});

describe('.startSpan()', () => {
Expand Down
Loading