From e7dad80daf392cdaf239fb19b5aac17e1c3a9001 Mon Sep 17 00:00:00 2001 From: Nicolas Hrubec Date: Fri, 26 Jun 2026 15:27:26 +0200 Subject: [PATCH] ref(node): Remove remaining OTel API from lru-memoizer instrumentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the last `@opentelemetry/api` usage (`context.bind(context.active(), …)`) with `withScope(getCurrentScope(), …)` from `@sentry/core`, matching the orchestrion lru-memoizer subscriber and mysql. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../tracing/lrumemoizer/vendored/instrumentation.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/node/src/integrations/tracing/lrumemoizer/vendored/instrumentation.ts b/packages/node/src/integrations/tracing/lrumemoizer/vendored/instrumentation.ts index 647456fdb663..f1e600b7359a 100644 --- a/packages/node/src/integrations/tracing/lrumemoizer/vendored/instrumentation.ts +++ b/packages/node/src/integrations/tracing/lrumemoizer/vendored/instrumentation.ts @@ -7,9 +7,8 @@ * - Upstream version: @opentelemetry/instrumentation-lru-memoizer@0.62.0 */ -import { context } from '@opentelemetry/api'; import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation'; -import { SDK_VERSION } from '@sentry/core'; +import { getCurrentScope, SDK_VERSION, withScope } from '@sentry/core'; const PACKAGE_NAME = '@sentry/instrumentation-lru-memoizer'; @@ -37,8 +36,13 @@ export class LruMemoizerInstrumentation extends InstrumentationBase { return function (this: unknown, ...memoizerArgs: unknown[]): unknown { // last argument is the callback const origCallback = memoizerArgs.pop(); + const scope = getCurrentScope(); const callbackWithContext = - typeof origCallback === 'function' ? context.bind(context.active(), origCallback) : origCallback; + typeof origCallback === 'function' + ? function (this: unknown, ...callbackArgs: unknown[]): unknown { + return withScope(scope, () => (origCallback as Memoizer).apply(this, callbackArgs)); + } + : origCallback; return origMemoizer.apply(this, [...memoizerArgs, callbackWithContext]); }; };