[bot] Google GenAI `generateImages` spans missing prompt input and use wrong span type
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- java
- Lĩnh vực
- observability
Hướng nghiên cứu
Bắt đầu tại braintrust-sdk/instrumentation/genai_1_18_0/src/main/java/com/google/genai/BraintrustApiClient.java, đặc biệt là tagSpan ở các dòng 97–161, và xem xét BraintrustGenAITest.java để tìm các assertion về span hiện có. Bổ sung coverage cho việc phân tích request và response của generateImages, bao gồm prompt, metadata tạo ảnh và việc phân loại span phù hợp; hoàn thành khi test xác minh rằng các giá trị này được ghi nhận, thay vì hành vi hiện tại chỉ xử lý generateContent.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
When client.models.generateImages() is called through the instrumented Google GenAI client, a span is created (the call goes through ApiClient.request()), but the span contains no useful input data. The tagSpan() method in BraintrustApiClient only extracts fields specific to generateContent (contents, generationConfig, usageMetadata), which are absent from image generation requests and responses.
The result:
input_jsononly has{model: "..."}— the actual prompt text is not captured. This is the primary creative input and the most important thing to trace for image generation.- No metrics — image generation responses use response-level metadata (not
usageMetadata), so no token or character counts are captured. - Wrong span type — hardcoded
type: "llm"instead of something appropriate for image generation.
This is analogous to the embedContent gap tracked in #65, where calls are intercepted at HTTP level but parsed with the wrong field schema.
Braintrust already documents and traces generate_images for the Python SDK. The Java SDK makes the same API calls but the span tagging logic was never extended to handle them.
What is missing
BraintrustApiClient.tagSpan() (lines 50–161) handles only generateContent fields:
Request parsing (lines 97–113):
if (requestJson.containsKey("contents")) { // generateContent field — not present in generateImages
inputJson.put("contents", requestJson.get("contents"));
}
if (requestJson.containsKey("generationConfig")) { // generateContent field — not present in generateImages
inputJson.put("config", requestJson.get("generationConfig"));
}
A generateImages request body looks like:
{
"prompt": "A photorealistic cat sitting on a moon",
"config": {
"numberOfImages": 2,
"aspectRatio": "16:9",
"negativePrompt": "blurry, low quality"
}
}
Neither prompt nor config.numberOfImages/config.aspectRatio are extracted. The input_json stored in the span ends up as {model: "imagen-3.0-generate-001"} only — the prompt is silently dropped.
Response parsing (lines 116–149):
if (responseJson.get("usageMetadata") instanceof Map) { // not present in generateImages responses
...
}
generateImages responses return generatedImages[].image.imageBytes (base64) and generatedImages[].generationParameters. No usageMetadata is present, so the metrics block is empty.
Span attributes (line 156):
span.setAttribute("braintrust.span_attributes", toJson(Map.of("type", "llm")));
Image generation is not an LLM call. Braintrust's Python tracer uses a different span categorization for image generation spans.
Braintrust docs status
- Braintrust docs at https://www.braintrust.dev/docs/integrations/ai-providers/gemini document
generate_imagesas a traced surface for Python: supported - No mention of
generateImagesinstrumentation for Java: not_found
Upstream sources
- Google GenAI Java SDK
generateImages:client.models.generateImages(String model, String prompt, GenerateImagesConfig config)— stable API, available in genai-java v1.18.0 (the version this module targets) - Imagen API reference: https://ai.google.dev/api/generate-images — documents
prompt,config(numberOfImages, aspectRatio, negativePrompt, safetyFilterLevel, personGeneration), andgeneratedImagesresponse format - Braintrust Python tracing:
generate_imagesand async variants are explicitly listed as traced surfaces at https://www.braintrust.dev/docs/integrations/ai-providers/gemini
Local files inspected
braintrust-sdk/instrumentation/genai_1_18_0/src/main/java/com/google/genai/BraintrustApiClient.java— lines 97–113 (tagSpaninput parsing: onlycontents/generationConfigextracted;promptfield absent); lines 116–149 (response parsing: onlyusageMetadatachecked; missing for image responses); line 156 (hardcodedtype: "llm")braintrust-sdk/instrumentation/genai_1_18_0/src/test/java/dev/braintrust/instrumentation/genai/v1_18_0/BraintrustGenAITest.java— nogenerateImagestest exists
- 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ự
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Đang mởarea/plugin
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
kestra-io/plugin-kestra#190 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
Add canonical URLs and a sitemap Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
apache/rocketmq-dashboard#5064 ·
-
Consent portal: creating a duplicate Purpose shows a generic error instead of "already exists" Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
wso2/dpdp-accelerator#287 ·