[bot] Google GenAI `generateImages` spans missing prompt input and use wrong span type
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- java
调研方向
从 braintrust-sdk/instrumentation/genai_1_18_0/src/main/java/com/google/genai/BraintrustApiClient.java 开始,重点查看第 97–161 行的 tagSpan,并检查 BraintrustGenAITest.java 中现有的 span 断言。为 generateImages 请求和响应的解析添加测试覆盖,包括 prompt、图像生成元数据以及适当的 span 分类;完成标准是测试能够验证这些值已被捕获,而不是当前仅支持 generateContent 的行为。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Java
- 星标
- 21
- 派生
- 5
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 8
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
braintrustdata/braintrust-sdk-java 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 68/100
查看 braintrustdata/braintrust-sdk-java 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
-
难度 2/5 1-3 小时 新手友好度 64/100
utopia-rise/godot-jvm#1004 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
spring-projects/spring-grpc#442 ·
-
Expose numberOfPermits in RateLimiterEvent.toString() and the ratelimiterevents actuator DTO可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
resilience4j/resilience4j#2547 ·
维护者通常 9 天内回复
-
Clock.MakeDate continues execution and returns a rolled-over instant after dispatching error on invalid date可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1 小时以内 新手友好度 82/100
mit-cml/appinventor-sources#4155 ·
维护者通常 1 天内回复