Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[bot] Google GenAI `generateImages` spans missing prompt input and use wrong span type

Đang mở
#121 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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_json only 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

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), and generatedImages response format
  • Braintrust Python tracing: generate_images and 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 (tagSpan input parsing: only contents/generationConfig extracted; prompt field absent); lines 116–149 (response parsing: only usageMetadata checked; missing for image responses); line 156 (hardcoded type: "llm")
  • braintrust-sdk/instrumentation/genai_1_18_0/src/test/java/dev/braintrust/instrumentation/genai/v1_18_0/BraintrustGenAITest.java — no generateImages test 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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của braintrustdata/braintrust-sdk-java

Tất cả issue của braintrustdata/braintrust-sdk-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.