LiteLLM integration does not report cached, reasoning, or cache-write token usage
@alexander-alderman-webb がすでに取り組んでいます。
2026年2月23日 から。
評価
この issue はまだ評価されていません。
説明
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.52.0
Steps to Reproduce
- Initialize Sentry with the LiteLLM integration and tracing enabled
- Make a completion call through LiteLLM to a provider that supports prompt caching (e.g., OpenAI, Anthropic, etc.)
- Inspect the resulting span data in Sentry's AI Agents dashboard
Expected Result
The span should include all available token usage detail attributes, just like the OpenAI and Anthropic integrations do:
gen_ai.usage.input_tokens(total input tokens)gen_ai.usage.input_tokens.cached(cached input tokens, subset of total)gen_ai.usage.input_tokens.cache_write(cache write tokens, if available)gen_ai.usage.output_tokens(total output tokens)gen_ai.usage.output_tokens.reasoning(reasoning tokens, subset of total)gen_ai.usage.total_tokens
This data is necessary for Sentry to correctly calculate model costs using the formula documented here:
input cost = (input_tokens - cached_tokens) x input_rate + cached_tokens x cached_rate
Without cached/reasoning token breakdown, all tokens are charged at the full standard rate, producing inaccurate cost estimates.
Actual Result
The LiteLLM integration's _success_callback only extracts three basic fields:
record_token_usage(
span,
input_tokens=getattr(usage, "prompt_tokens", None),
output_tokens=getattr(usage, "completion_tokens", None),
total_tokens=getattr(usage, "total_tokens", None),
)
The input_tokens_cached, input_tokens_cache_write, and output_tokens_reasoning parameters of record_token_usage() are never passed. Therefore, cost calculations in the AI Agents dashboard overestimate costs for cached-heavy workloads (all input tokens billed at the full rate) and misattribute output vs. reasoning token costs.
- 主要言語
- Python
- スター
- 2.2k
- フォーク
- 672
- 平均マージ
- 22時間 47分
- マージ済み PR(30日)
- 224
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-python のほかの issue
-
Python
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
getsentry/sentry-python#7569 · コメント 1 件 ·
-
Python
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
getsentry/sentry-python#7568 · コメント 2 件 ·
-
Python
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
getsentry/sentry-python#7567 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
getsentry/sentry-python#7543 · コメント 2 件 · 担当者 1 名 ·
-
Python
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
getsentry/sentry-python#6992 · コメント 1 件 ·
getsentry/sentry-python の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
canonical/paas-charm#368 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
StevenBlack/hosts#3256 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
qualcomm/qai-appbuilder#275 ·