From a90c558772e049d614f91c8046b60c49f3211de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20St=C3=B6bich?= Date: Fri, 27 Jan 2023 18:58:41 +0100 Subject: [PATCH] fix(sdk-node): register instrumentations early (#3502) * fix(sdk-node): register instrumentations early Register instrumentations as first step in start() before it gets async to ensure that modules required during async resource detection get instrumented. * Update experimental/CHANGELOG.md --------- Co-authored-by: Daniel Dyla --- experimental/CHANGELOG.md | 1 + experimental/packages/opentelemetry-sdk-node/src/sdk.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 44c40824e4..40f2bcbbfa 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to experimental packages in this project will be documented ### :bug: (Bug Fix) +* fix(sdk-node): register instrumentations early [#3502](https://github.com/open-telemetry/opentelemetry-js/pull/3502) @flarna * fix: include tracestate in export [#3569](https://github.com/open-telemetry/opentelemetry-js/pull/3569) @flarna ### :books: (Refine Doc) diff --git a/experimental/packages/opentelemetry-sdk-node/src/sdk.ts b/experimental/packages/opentelemetry-sdk-node/src/sdk.ts index a3af268442..caad9b85e2 100644 --- a/experimental/packages/opentelemetry-sdk-node/src/sdk.ts +++ b/experimental/packages/opentelemetry-sdk-node/src/sdk.ts @@ -208,6 +208,10 @@ export class NodeSDK { return; } + registerInstrumentations({ + instrumentations: this._instrumentations, + }); + if (this._autoDetectResources) { await this.detectResources(); } @@ -255,10 +259,6 @@ export class NodeSDK { metrics.setGlobalMeterProvider(meterProvider); } - - registerInstrumentations({ - instrumentations: this._instrumentations, - }); } public shutdown(): Promise {