Anthropic gen_ai span never ends when a streaming call is consumed via .asResponse()
@RulaKhaled がすでに取り組んでいます。
2026年9月9日 から。
評価
この issue はまだ評価されていません。
説明
Problem
anthropicAIIntegration starts a gen_ai.chat span for messages.create({ stream: true }) but never ends it when the caller takes the raw Response via .asResponse() (or .withResponse()) instead of iterating the SDK's Stream. The span is silently dropped — no error, no partial data.
Cause
packages/server-utils/src/integrations/anthropic.ts:147 — wrapStreamResult checks isAsyncIterable(result). With .asResponse() the result is a raw Response, so the check fails and it returns false, meaning "end via beforeSpanEnd". beforeSpanEnd never fires, so nothing ends the span.
Repro
Two identical streaming calls, one per consumption style:
const client = new Anthropic({ apiKey: 'sk-fake', baseURL: 'http://127.0.0.1:3999' });
// A: raw Response
const res = await client.messages.create({ ...params, stream: true }).asResponse();
for await (const _ of res.body) {}
// B: SDK async iterable
const stream = await client.messages.create({ ...params, stream: true });
for await (const _ of stream) {}
Span lifecycle:
[spanStart] chat claude-haiku-4-5 <- A
[spanStart] chat claude-haiku-4-5 <- B
[spanEnd] chat claude-haiku-4-5 <- only one ends
Impact
Any consumer using .asResponse()/.withResponse() on a streaming call loses the span. Found via @flue/runtime, whose @earendil-works/pi-ai layer calls client.messages.create({ ...params, stream: true }, opts).asResponse() — a Flue app currently reports only a raw http.client span for every LLM call. Not Flue-specific.
Verified on @sentry/node@11.0.0-beta.2, @anthropic-ai/sdk@0.91.1, Node 24.11.1.
- 主要言語
- TypeScript
- スター
- 8.7k
- フォーク
- 1.9k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 562
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-javascript のほかの issue
-
Browser Waiting for: Product Owner
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
getsentry/sentry-javascript#24577 · コメント 1 件 ·
-
Task
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
getsentry/sentry-javascript#24558 · コメント 1 件 ·
-
Task
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
getsentry/sentry-javascript#24557 · コメント 1 件 ·
-
Task
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
getsentry/sentry-javascript#24556 · コメント 1 件 ·
-
Task
難易度 1/5 1〜3時間 初心者へのやさしさ 90/100
getsentry/sentry-javascript#24555 · コメント 1 件 ·
getsentry/sentry-javascript の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
safetrustcr/dApp-SafeTrust#426 ·
-
area:workflow bug ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
fil-donadoni/tolaria#4409 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Fission-AI/OpenSpec#1960 ·
-
Add dependabot オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
corsairdev/corsair#1764 ·