Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

otelMiddleware: media generation spans never capture prompt, input media or output, even with captureContent

クローズ
#1,526 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@AlemTuzlak がすでに取り組んでいます。

2026年9月27日 から。

評価

この issue はまだ評価されていません。

説明

waiting-on: maintainer

Summary

otelMiddleware opens one CLIENT span for each media activity call (generateImage, generateVideo, generateAudio, generateSpeech, generateTranscription, …), added via #720. That span carries the provider, the model, the operation name and usage. It never records what was asked for or what came back, even with captureContent: true:

  • no prompt
  • no input media: reference images, start and end frames, source audio for transcription
  • no output: generated image, video or audio URLs, or the transcript text

In PostHog, Langfuse or Datadog every media generation therefore shows up as an empty Input/Output pair with a cost attached. For image-to-video or reference-to-video, where the result depends mostly on the input images, there is nothing in the trace to debug from.

Root cause

startMediaSpan / endMediaSpan (packages/ai/src/middlewares/otel.ts:343–384) only set gen_ai.system, gen_ai.operation.name, gen_ai.request.model and usage. captureContent is only checked on the chat paths.

The inputs are already on the context: GenerationMiddlewareContext.artifactInputs holds the activity inputs. The media path never reads it, and the result is never inspected in the terminal hook.

The only workaround is attributeEnricher / onSpanEnd in every app, reimplementing the per-activity input and output shapes that the library already knows.

Proposal

When captureContent is on, the media span writes the same attributes the chat iteration spans do:

  • gen_ai.input.messages / langfuse.observation.input: the prompt as a text part, plus each input media reference as a URI part ({ type: 'uri', modality, uri }), reusing whatever part serialisation #1525 lands on.
  • gen_ai.output.messages / langfuse.observation.output: output media URLs as URI parts, and transcript text as a text part.
  • Inline or base64 inputs and outputs follow the same rule as #1525: a placeholder by default, and an opt-in hook to swap in a URL. redact and maxContentLength still apply.

Related

  • #720: added the media span (closed)
  • #1525: captureContent drops non-text parts on chat spans

Version

@tanstack/ai 0.58.0 (current main has the same code).

I'm happy to open a PR.

主要言語
TypeScript
スター
3.1k
フォーク
340
平均マージ
2日 10時間
マージ済み PR(30日)
175

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TanStack/ai のほかの issue

TanStack/ai の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。