From 1859bc98d1208fc891a80b5caeab290b1b322bdf Mon Sep 17 00:00:00 2001 From: Shashikiran Budde Date: Wed, 16 Aug 2023 14:38:03 +0200 Subject: [PATCH] chore(sdk-node): deprecate methods in favor of constructor options (#3996) --- experimental/CHANGELOG.md | 8 ++++ .../package.json | 2 +- .../package.json | 2 +- .../opentelemetry-sdk-node/src/sdk.ts | 37 ++++++++++++++++--- .../packages/shim-opencensus/package.json | 2 +- .../opentelemetry-sdk-trace-node/package.json | 2 +- 6 files changed, 43 insertions(+), 10 deletions(-) diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 64b4debd388..0c4f724d83e 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -8,6 +8,14 @@ All notable changes to experimental packages in this project will be documented ### :boom: Breaking Change +* chore(sdk-node): deprecate methods in favor of constructor options [#3996](https://github.com/open-telemetry/opentelemetry-js/pull/3996) @pichlermarc + * The following methods are now deprecated and will be removed in `0.43.0` + * `NodeSDK.configureTracerProvider()`, please use constructor options instead + * `NodeSDK.configureMeterProvider()`, please use constructor options instead + * `NodeSDK.configureLoggerProvider()`, please use constructor options instead + * `NodeSDK.addResource()`, please use constructor options instead + * `NodeSDK.detectResources()`, this is not necessary anymore, resources are now auto-detected on startup. + ### :rocket: (Enhancement) ### :bug: (Bug Fix) diff --git a/experimental/packages/opentelemetry-instrumentation-http/package.json b/experimental/packages/opentelemetry-instrumentation-http/package.json index 19b0d565126..ed70652dfe6 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/package.json +++ b/experimental/packages/opentelemetry-instrumentation-http/package.json @@ -77,7 +77,7 @@ "@opentelemetry/core": "1.15.2", "@opentelemetry/instrumentation": "0.41.2", "@opentelemetry/semantic-conventions": "1.15.2", - "semver": "^7.5.1" + "semver": "^7.5.2" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-http", "sideEffects": false diff --git a/experimental/packages/opentelemetry-instrumentation/package.json b/experimental/packages/opentelemetry-instrumentation/package.json index 85905869530..497ddb1b219 100644 --- a/experimental/packages/opentelemetry-instrumentation/package.json +++ b/experimental/packages/opentelemetry-instrumentation/package.json @@ -74,7 +74,7 @@ "@types/shimmer": "^1.0.2", "import-in-the-middle": "1.4.2", "require-in-the-middle": "^7.1.1", - "semver": "^7.5.1", + "semver": "^7.5.2", "shimmer": "^1.2.1" }, "peerDependencies": { diff --git a/experimental/packages/opentelemetry-sdk-node/src/sdk.ts b/experimental/packages/opentelemetry-sdk-node/src/sdk.ts index 8b96dddeab8..30a1bea7901 100644 --- a/experimental/packages/opentelemetry-sdk-node/src/sdk.ts +++ b/experimental/packages/opentelemetry-sdk-node/src/sdk.ts @@ -178,7 +178,14 @@ export class NodeSDK { this._instrumentations = instrumentations; } - /** Set configurations required to register a NodeTracerProvider */ + /** + * + * @deprecated Please pass {@code sampler}, {@code generalLimits}, {@code spanLimits}, {@code resource}, + * {@code IdGenerator}, {@code spanProcessor}, {@code contextManager} and {@code textMapPropagator}, + * to the constructor options instead. + * + * Set configurations needed to register a TracerProvider + */ public configureTracerProvider( tracerConfig: NodeTracerConfig, spanProcessor: SpanProcessor, @@ -193,7 +200,11 @@ export class NodeSDK { }; } - /**Set configurations needed to register a LoggerProvider */ + /** + * @deprecated Please pass {@code logRecordProcessor} to the constructor options instead. + * + * Set configurations needed to register a LoggerProvider + */ public configureLoggerProvider(config: LoggerProviderConfig): void { // nothing is set yet, we can set config and then return if (this._loggerProviderConfig == null) { @@ -217,7 +228,11 @@ export class NodeSDK { } } - /** Set configurations needed to register a MeterProvider */ + /** + * @deprecated Please pass {@code views} and {@code reader} to the constructor options instead. + * + * Set configurations needed to register a MeterProvider + */ public configureMeterProvider(config: MeterProviderConfig): void { // nothing is set yet, we can set config and return. if (this._meterProviderConfig == null) { @@ -248,7 +263,12 @@ export class NodeSDK { } } - /** Detect resource attributes */ + /** + * @deprecated Resources are detected automatically on {@link NodeSDK.start()}, when the {@code autoDetectResources} + * constructor option is set to {@code true} or left {@code undefined}. + * + * Detect resource attributes + */ public detectResources(): void { if (this._disabled) { return; @@ -261,13 +281,18 @@ export class NodeSDK { this.addResource(detectResourcesSync(internalConfig)); } - /** Manually add a resource */ + /** + * @deprecated Please pre-merge resources and pass them to the constructor + * + * Manually add a Resource + * @param resource + */ public addResource(resource: IResource): void { this._resource = this._resource.merge(resource); } /** - * Once the SDK has been configured, call this method to construct SDK components and register them with the OpenTelemetry API. + * Call this method to construct SDK components and register them with the OpenTelemetry API. */ public start(): void { if (this._disabled) { diff --git a/experimental/packages/shim-opencensus/package.json b/experimental/packages/shim-opencensus/package.json index 3c9d4e82073..75651fc7538 100644 --- a/experimental/packages/shim-opencensus/package.json +++ b/experimental/packages/shim-opencensus/package.json @@ -71,7 +71,7 @@ "dependencies": { "@opentelemetry/core": "1.15.2", "require-in-the-middle": "^7.1.1", - "semver": "^7.5.1" + "semver": "^7.5.2" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/shim-opencensus", "sideEffects": false diff --git a/packages/opentelemetry-sdk-trace-node/package.json b/packages/opentelemetry-sdk-trace-node/package.json index bd88e07fdb9..f4d44f0f97d 100644 --- a/packages/opentelemetry-sdk-trace-node/package.json +++ b/packages/opentelemetry-sdk-trace-node/package.json @@ -70,7 +70,7 @@ "@opentelemetry/propagator-b3": "1.15.2", "@opentelemetry/propagator-jaeger": "1.15.2", "@opentelemetry/sdk-trace-base": "1.15.2", - "semver": "^7.5.1" + "semver": "^7.5.2" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node", "sideEffects": false