Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

OpenAI integration does not record cache-write tokens

未关闭 适合新手
#7,870 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
observability

调研方向

从 integrations/openai.py 第 283-289 行附近开始,检查 responses 和 chat-completions 的使用详情如何转换为 span 属性。为两种使用数据结构中的缓存写入 token 添加测试覆盖,然后运行 OpenAI 集成测试,并确认记录了 gen_ai.usage.input_tokens.cache_write。

由索引模型根据 Issue 内容生成。

描述

Bug Python
Version

2.71.0 (master @ 6a4eb20)

Steps to Reproduce

Call client.responses.create(...) or client.chat.completions.create(...) and get a response whose usage has input_tokens_details.cache_write_tokens (or prompt_tokens_details.cache_write_tokens) set, e.g. 96.

Expected Result

The span has gen_ai.usage.input_tokens.cache_write = 96, like the Anthropic integration.

Actual Result

No cache-write attribute. _calculate_responses_token_usage and _calculate_completions_token_usage only read cached_tokens (openai.py#L283-L289).

I have a small fix with a test: https://github.com/4ktLuffy/sentry-python/tree/fix/openai-cache-write-tokens. Happy to open a PR if that works for you.

主要语言
Python
星标
2.2k
派生
682
平均合并
1 天 5 小时
30 天内合并 PR
269

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry-python 的其他 Issue

查看 getsentry/sentry-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。