[bot] OpenAI Images API spans missing input/output capture
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- java
- Lĩnh vực
- api, observability
Hướng nghiên cứu
Bắt đầu trong braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java, đọc tagOpenAIRequest(), tagOpenAIResponse() và getSpanName(), sau đó kiểm tra các cassette fixture hiện có của OpenAI chat_completions và responses. Thêm coverage cho Images API đối với các lời gọi generate, edit và variation; được xem là hoàn thành khi các span capture dữ liệu request và response hình ảnh đã được ghi nhận, usage khi áp dụng, cùng một tên span dễ đọc đối với con người, với tests hoặc fixtures bao quát hành vi này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The OpenAI instrumentation intercepts every HTTP call made through the OpenAI Java client's HttpClient (generic, transport-level wrapping), so calls to the Images API (client.images().generate(), .edit(), .createVariation()) do produce a span. However, InstrumentationSemConv's request/response tagging logic only recognizes the Chat Completions (messages/choices) and Responses API (input/output) JSON shapes. Images API requests and responses use neither shape, so the resulting spans have no useful input or output data — the same class of gap already fixed/tracked for embeddings (#66) and audio (#131), but not yet filed for Images.
What is missing
InstrumentationSemConv.tagOpenAIRequest() (lines 127–138 of braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java):
if (requestJson.has("messages")) {
span.setAttribute("braintrust.input_json", toJson(requestJson.get("messages")));
} else if (requestJson.has("input") && requestJson.get("input").isArray()) {
span.setAttribute("braintrust.input_json", toJson(requestJson.get("input")));
}
An images.generate request body looks like:
{
"model": "gpt-image-1",
"prompt": "A photorealistic cat sitting on a moon",
"size": "1024x1024",
"quality": "high",
"n": 1
}
prompt is a plain string (not messages, not an input array), so neither branch matches — braintrust.input_json is never set for Images API calls. size, quality, n, and style are also dropped since only model is captured into metadata.
InstrumentationSemConv.tagOpenAIResponse() (lines 144–201) only sets braintrust.output_json when the response has choices or output:
if (responseJson.has("choices")) {
span.setAttribute("braintrust.output_json", toJson(responseJson.get("choices")));
} else if (responseJson.has("output")) {
span.setAttribute("braintrust.output_json", toJson(responseJson.get("output")));
}
An images.generate response returns {"data": [{"url": "...", "revised_prompt": "..."}], ...} (or b64_json instead of url). Neither choices nor output is present, so braintrust.output_json is never set — the generated image URL/base64 data and revised_prompt are silently dropped. No usage extraction exists for the Images API's token-based billing on gpt-image-1 either.
The span name mapping in getSpanName() (lines 511–522) also has no case for the images/generations / images/edits / images/variations path segments, so the span name falls back to the raw last path segment instead of a human-readable name like the existing "Chat Completion"/"Embeddings" cases.
Braintrust docs status
- not_found — the Braintrust OpenAI integration docs at https://www.braintrust.dev/docs/integrations/ai-providers/openai document streaming audio transcription tracing ("Braintrust traces streaming audio transcription calls for sync and async OpenAI clients") but make no mention of the Images API or image generation tracing for any language.
Upstream sources
- OpenAI Images API reference: https://platform.openai.com/docs/api-reference/images/create — documents
prompt(string, required),size,quality,n,style,response_format, and the responsedata[]array withurl/b64_json/revised_prompt - OpenAI Java SDK:
client.images().generate(ImageGenerateParams),.edit(ImageEditParams),.createVariation(ImageCreateVariationParams)— stable, documented methods oncom.openai:openai-java(this repo pins2.15.0,)) - gpt-image-1 token-based usage: https://platform.openai.com/docs/guides/image-generation —
gpt-image-1responses include ausageobject withinput_tokens/output_tokens, distinct from the legacy DALL·E per-image pricing
Local files inspected
braintrust-sdk/src/main/java/dev/braintrust/instrumentation/InstrumentationSemConv.java— lines 110–141 (tagOpenAIRequest: onlymessages/array-inputhandled), lines 143–201 (tagOpenAIResponse: onlychoices/outputhandled), lines 511–522 (getSpanName: no case forimages/*paths)braintrust-sdk/instrumentation/openai_2_15_0/src/main/java/dev/braintrust/instrumentation/openai/v2_15_0/TracingHttpClient.java— generic HTTP-level wrapping; delegates all tagging toInstrumentationSemConvtest-harness/src/testFixtures/resources/cassettes/openai/mappings/— onlychat_completions-*andresponses-*cassette files exist; noimages-*cassette or test exists anywhere in the repo (confirmed via repo-wide search)
- Ngôn ngữ chính
- Java
- Star
- 21
- Fork
- 5
- Merge trung bình
- 2 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 8
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của braintrustdata/braintrust-sdk-java
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Tất cả issue của braintrustdata/braintrust-sdk-java
Issue tương tự
-
certification
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's Đang mởbug ecr
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Needs: Triage Type: Feature request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
AntennaPod/AntennaPod#8794 ·
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/copilot-sdk#2760 ·