Skip to content

Commit 7ad75b5

Browse files
committed
fix client lookup
1 parent 15f8378 commit 7ad75b5

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

packages/node/src/integrations/tracing/anthropic-ai/instrumentation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
InstrumentationNodeModuleDefinition,
66
} from '@opentelemetry/instrumentation';
77
import type { AnthropicAiClient, AnthropicAiOptions, Integration } from '@sentry/core';
8-
import { ANTHROPIC_AI_INTEGRATION_NAME, getCurrentScope, instrumentAnthropicAiClient, SDK_VERSION } from '@sentry/core';
8+
import { ANTHROPIC_AI_INTEGRATION_NAME, getClient, instrumentAnthropicAiClient, SDK_VERSION } from '@sentry/core';
99

1010
const supportedVersions = ['>=0.19.2 <1.0.0'];
1111

@@ -61,10 +61,10 @@ export class SentryAnthropicAiInstrumentation extends InstrumentationBase<Instru
6161

6262
const WrappedAnthropic = function (this: unknown, ...args: unknown[]) {
6363
const instance = Reflect.construct(Original, args);
64-
const scopeClient = getCurrentScope().getClient();
65-
const integration = scopeClient?.getIntegrationByName<AnthropicAiIntegration>(ANTHROPIC_AI_INTEGRATION_NAME);
64+
const client = getClient();
65+
const integration = client?.getIntegrationByName<AnthropicAiIntegration>(ANTHROPIC_AI_INTEGRATION_NAME);
6666
const integrationOpts = integration?.options;
67-
const defaultPii = Boolean(scopeClient?.getOptions().sendDefaultPii);
67+
const defaultPii = Boolean(client?.getOptions().sendDefaultPii);
6868

6969
const { recordInputs, recordOutputs } = determineRecordingSettings(integrationOpts, defaultPii);
7070

packages/node/src/integrations/tracing/openai/instrumentation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
InstrumentationNodeModuleDefinition,
66
} from '@opentelemetry/instrumentation';
77
import type { Integration, OpenAiClient, OpenAiOptions } from '@sentry/core';
8-
import { getCurrentScope, instrumentOpenAiClient, OPENAI_INTEGRATION_NAME, SDK_VERSION } from '@sentry/core';
8+
import { getClient, instrumentOpenAiClient, OPENAI_INTEGRATION_NAME, SDK_VERSION } from '@sentry/core';
99

1010
const supportedVersions = ['>=4.0.0 <6'];
1111

@@ -57,10 +57,10 @@ export class SentryOpenAiInstrumentation extends InstrumentationBase<Instrumenta
5757

5858
const WrappedOpenAI = function (this: unknown, ...args: unknown[]) {
5959
const instance = Reflect.construct(Original, args);
60-
const scopeClient = getCurrentScope().getClient();
61-
const integration = scopeClient?.getIntegrationByName<OpenAiIntegration>(OPENAI_INTEGRATION_NAME);
60+
const client = getClient();
61+
const integration = client?.getIntegrationByName<OpenAiIntegration>(OPENAI_INTEGRATION_NAME);
6262
const integrationOpts = integration?.options;
63-
const defaultPii = Boolean(scopeClient?.getOptions().sendDefaultPii);
63+
const defaultPii = Boolean(client?.getOptions().sendDefaultPii);
6464

6565
const { recordInputs, recordOutputs } = determineRecordingSettings(integrationOpts, defaultPii);
6666

packages/node/src/integrations/tracing/vercelai/instrumentation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
addNonEnumerableProperty,
88
captureException,
99
getActiveSpan,
10-
getCurrentScope,
10+
getClient,
1111
handleCallbackErrors,
1212
isThenable,
1313
SDK_VERSION,
@@ -218,7 +218,7 @@ export class SentryVercelAiInstrumentation extends InstrumentationBase {
218218
const existingExperimentalTelemetry = args[0].experimental_telemetry || {};
219219
const isEnabled = existingExperimentalTelemetry.isEnabled;
220220

221-
const client = getCurrentScope().getClient();
221+
const client = getClient();
222222
const integration = client?.getIntegrationByName<VercelAiIntegration>(INTEGRATION_NAME);
223223
const integrationOptions = integration?.options;
224224
const shouldRecordInputsAndOutputs = integration ? Boolean(client?.getOptions().sendDefaultPii) : false;

0 commit comments

Comments
 (0)