[bot] OpenAI Responses API instrumentation only captures response `id`, missing status/service_tier/model/etc.
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 65/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- ruby
调研方向
Examine the two files mentioned: lib/braintrust/contrib/openai/instrumentation/responses.rb and lib/braintrust/contrib/ruby_openai/instrumentation/responses.rb. Compare their finalize_metadata methods with the sibling chat.rb implementation to see the pattern for capturing response fields. Add the missing fields (status, incomplete_details, error, model, service_tier, created_at, background) from the OpenAI::Models::Responses::Response object. Verify the changes by running any existing tests for the instrumentation or creating a small script to ensure the metadata is populated correctly.
由索引模型根据 Issue 内容生成。
描述
Summary
The Responses API instrumentation in both the openai and ruby-openai integrations captures almost none of the response object's fields into span metadata after the call completes. finalize_metadata only ever sets metadata["id"]. This is materially less detail than the sibling Chat Completions instrumentation in this same SDK, which captures id, created, model, system_fingerprint, and service_tier from the response object after every call (including streaming).
This is a distinct gap from #145 (which covers wrong/missing request-side METADATA_FIELDS, e.g. max_tokens vs max_output_tokens). This issue is about response-side fields that are dropped after the call returns.
What is missing
The upstream Responses API response object (OpenAI::Models::Responses::Response) exposes at minimum:
status— e.g.completed,incomplete,failed,in_progress— critical for knowing whether a generation actually finished successfullyincomplete_details— explains why a response is incomplete (e.g. hitmax_output_tokens) — directly useful for debugging truncated generationserror— error details when the response object itself reports a failuremodel— the actual model that served the request (may differ from the requested model, e.g. due to aliasing)service_tier— the processing tier that actually served the request (may differ from the requested tier)created_at— response creation timestampbackground— whether the response was run in background/async mode
None of these are captured. The current finalize_metadata implementations:
# lib/braintrust/contrib/openai/instrumentation/responses.rb:109-112
def finalize_metadata(span, metadata, response)
metadata["id"] = response.id if response.respond_to?(:id) && response.id
Support::OTel.set_json_attr(span, "braintrust.metadata", metadata)
end
# lib/braintrust/contrib/ruby_openai/instrumentation/responses.rb:137-140
def finalize_metadata(span, metadata, response_data)
metadata["id"] = response_data["id"] if response_data["id"]
Support::OTel.set_json_attr(span, "braintrust.metadata", metadata)
end
only ever set id. The same gap exists in the streaming path (ResponseStream#finalize_stream_span in lib/braintrust/contrib/openai/instrumentation/responses.rb:164-181, and Common.aggregate_responses_chunks/aggregate_responses_events in the respective common.rb files), which likewise only propagate id through to metadata.
For contrast, the parallel Chat Completions finalize_metadata (lib/braintrust/contrib/openai/instrumentation/chat.rb:129-136) captures id, created, model, system_fingerprint, and service_tier — showing this is an internal inconsistency between two instrumented surfaces for the same underlying gem, not a hard technical limitation.
Braintrust docs status
unclear — https://www.braintrust.dev/docs/guides/tracing states that Braintrust auto-instrumentation captures "Model parameters (model name, temperature, etc.)" generally, and the Braintrust docs' own Responses API example (openai.responses.create(...)) is presented as fully auto-traced with "inputs, outputs, latency, tokens, and cost" — but no page enumerates which specific response-object fields (status, incomplete_details, service_tier, etc.) should end up in span metadata for the Responses API.
Upstream sources
- Official OpenAI Ruby SDK: https://github.com/openai/openai-ruby —
OpenAI::Models::Responses::Response(lib/openai/models/responses/response.rb) definesstatus,incomplete_details,error,model,service_tier,created_at,background - OpenAI Responses API reference: https://platform.openai.com/docs/api-reference/responses/create — documents the response object schema, including
statusvalues (completed,failed,in_progress,incomplete) andincomplete_details.reason(e.g.max_output_tokens) - OpenAI cookbook example response payload confirming these fields: https://cookbook.openai.com/examples/responses_api/reasoning_items (shows
id,created_at,error,incomplete_details,modelon a real response object)
Braintrust docs sources checked
Local repo files inspected
lib/braintrust/contrib/openai/instrumentation/responses.rb(lines 109-112, 164-181) —finalize_metadataand streamingfinalize_stream_spanonly ever setmetadata["id"]lib/braintrust/contrib/ruby_openai/instrumentation/responses.rb(lines 137-140) — identicalfinalize_metadata, same gaplib/braintrust/contrib/openai/instrumentation/chat.rb(lines 129-136) — sibling Chat Completionsfinalize_metadatacapturesid,created,model,system_fingerprint,service_tier, demonstrating the established pattern this SDK already uses elsewherelib/braintrust/contrib/openai/instrumentation/common.rb(aggregate_responses_events, lines 112-129) — only returnsid,output,usagefrom the completed event's response, droppingstatus/incomplete_details/model/service_tier/errorlib/braintrust/contrib/ruby_openai/instrumentation/common.rb— analogous streaming aggregator for ruby-openai (not re-quoted here, same field-dropping pattern)
- 主要语言
- Ruby
- 星标
- 9
- 派生
- 10
- 平均合并
- 22 小时 10 分钟
- 30 天内合并 PR
- 6
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
braintrustdata/braintrust-sdk-ruby 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 5/5 一周以上 新手友好度 38/100
-
难度 4/5 3-5 天 新手友好度 55/100
查看 braintrustdata/braintrust-sdk-ruby 的全部 Issue
相似的 Issue
-
security
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
OSCON 2016未关闭content
难度 2/5 1-3 小时 新手友好度 68/100
rubyevents/rubyevents#2148 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
we-promise/sure#3838 · 2 条评论 ·
维护者通常 1 天内回复
-
Mend: dependency security vulnerability
难度 2/5 1-3 小时 新手友好度 68/100
ManageIQ/manageiq-ui-classic#10341 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
rubocop/ruby-style-guide#984 ·