Skip to content

Commit

Permalink
feat(sdk-trace-web): do not throw when passing extra options (#5357)
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Jan 27, 2025
1 parent 321c31f commit 199fd8d
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 55 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se

### :rocket: (Enhancement)

* feat(sdk-trace-web): do not throw when passing extra options [#5357](https://github.com/open-telemetry/opentelemetry-js/pull/5357) @pichlermarc
* `WebTracerProvider` constructor now does not throw anymore when `contextManager` or `propagator` are passed as extra options to the constructor
* feat(sdk-trace-base): add stack trace warning to debug instrumentation [#5363](https://github.com/open-telemetry/opentelemetry-js/pull/5363) @neilfordyce

### :bug: (Bug Fix)
Expand Down
2 changes: 0 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/opentelemetry-sdk-trace-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"@babel/preset-env": "7.26.7",
"@opentelemetry/api": ">=1.0.0 <1.10.0",
"@opentelemetry/context-zone": "1.30.0",
"@opentelemetry/propagator-b3": "1.30.0",
"@opentelemetry/resources": "1.30.0",
"@types/jquery": "3.5.32",
"@types/mocha": "10.0.10",
Expand Down
10 changes: 0 additions & 10 deletions packages/opentelemetry-sdk-trace-web/src/WebTracerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,6 @@ export class WebTracerProvider extends BasicTracerProvider {
*/
constructor(config: WebTracerConfig = {}) {
super(config);

if ((config as SDKRegistrationConfig).contextManager) {
throw (
'contextManager should be defined in register method not in' +
' constructor'
);
}
if ((config as SDKRegistrationConfig).propagator) {
throw 'propagator should be defined in register method not in constructor';
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import { context, ContextManager, trace } from '@opentelemetry/api';
import { ZoneContextManager } from '@opentelemetry/context-zone';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { Resource } from '@opentelemetry/resources';
import { SEMRESATTRS_TELEMETRY_SDK_LANGUAGE } from '@opentelemetry/semantic-conventions';
import { Span, Tracer } from '@opentelemetry/sdk-trace-base';
Expand Down Expand Up @@ -53,38 +52,6 @@ describe('WebTracerProvider', () => {
});
});

it('should throw error when context manager is passed in constructor', () => {
let error = '';
try {
new WebTracerProvider({
contextManager: new ZoneContextManager(),
} as any);
} catch (e) {
error = e;
}
assert.strictEqual(
error,
'contextManager should be defined in' +
' register method not in constructor'
);
});

it('should throw error when propagator is passed in constructor', () => {
let error = '';
try {
new WebTracerProvider({
propagator: new B3Propagator(),
} as any);
} catch (e) {
error = e;
}
assert.strictEqual(
error,
'propagator should be defined in register' +
' method not in constructor'
);
});

describe('when contextManager is "ZoneContextManager"', () => {
it('should correctly return the contexts for 2 parallel actions', done => {
const webTracerWithZone = new WebTracerProvider().getTracer('default');
Expand Down
3 changes: 0 additions & 3 deletions packages/opentelemetry-sdk-trace-web/tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
{
"path": "../opentelemetry-core"
},
{
"path": "../opentelemetry-propagator-b3"
},
{
"path": "../opentelemetry-resources"
},
Expand Down
3 changes: 0 additions & 3 deletions packages/opentelemetry-sdk-trace-web/tsconfig.esnext.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
{
"path": "../opentelemetry-core"
},
{
"path": "../opentelemetry-propagator-b3"
},
{
"path": "../opentelemetry-resources"
},
Expand Down
3 changes: 0 additions & 3 deletions packages/opentelemetry-sdk-trace-web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
{
"path": "../opentelemetry-core"
},
{
"path": "../opentelemetry-propagator-b3"
},
{
"path": "../opentelemetry-resources"
},
Expand Down

0 comments on commit 199fd8d

Please sign in to comment.