Skip to content

Commit 93118f3

Browse files
committed
Move target.apply down into startSpanManual
1 parent 945a7dc commit 93118f3

File tree

1 file changed

+1
-2
lines changed
  • packages/core/src/utils/anthropic-ai

1 file changed

+1
-2
lines changed

packages/core/src/utils/anthropic-ai/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ function instrumentMethod<T extends unknown[], R>(
210210
const isStreamingMethod = methodPath === 'messages.stream';
211211

212212
if (isStreamRequested || isStreamingMethod) {
213-
const messageStream = target.apply(context, args);
214-
215213
// Create span for instrumentation using startSpanManual
216214
return startSpanManual(
217215
{
@@ -225,6 +223,7 @@ function instrumentMethod<T extends unknown[], R>(
225223
addPrivateRequestAttributes(span, params);
226224
}
227225

226+
const messageStream = target.apply(context, args);
228227
return instrumentStream(messageStream, span, options.recordOutputs ?? false);
229228
} catch (error) {
230229
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });

0 commit comments

Comments
 (0)