Skip to content

Commit 9bf91c6

Browse files
committed
Move recording check up and early return
1 parent 4c7e9b1 commit 9bf91c6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ function processEvent(
211211
* Finalizes span attributes when stream processing completes
212212
*/
213213
function finalizeStreamSpan(state: StreamingState, span: Span, recordOutputs: boolean): void {
214+
if (!span.isRecording()) {
215+
return;
216+
}
217+
214218
// Set common response attributes if available
215219
if (state.responseId) {
216220
span.setAttributes({
@@ -254,9 +258,7 @@ function finalizeStreamSpan(state: StreamingState, span: Span, recordOutputs: bo
254258
});
255259
}
256260

257-
if (span.isRecording()) {
258-
span.end();
259-
}
261+
span.end();
260262
}
261263

262264
/**

0 commit comments

Comments
 (0)