[BOT ISSUE] Google GenAI (Gemini) streaming calls are not instrumented
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- java
- Domain
- observability
Research direction
Start with BraintrustApiClient.java lines 186–312 and inspect the upstream ApiClient streaming methods used by generateContentStream. Compare the SSE handling and chunk accumulation in the OpenAI and Anthropic TracingHttpClient implementations, then review BraintrustGenAITest.java. Done means streaming Gemini calls produce spans, output capture, and token usage metrics.
Written by the indexing model from the issue text.
Description
Summary
The Google GenAI instrumentation wraps ApiClient.request() and ApiClient.asyncRequest() for synchronous and asynchronous non-streaming calls, but does not override any streaming methods. Calls to client.models.generateContentStream() and similar streaming APIs bypass the instrumentation entirely, producing no spans, no output capture, and no token usage metrics.
What is missing
BraintrustApiClient.java overrides 4 methods:
request(String, String, String, Optional)(line 186)request(String, String, byte[], Optional)(line 210)asyncRequest(String, String, String, Optional)(line 239)asyncRequest(String, String, byte[], Optional)(line 277)
The upstream ApiClient class in the Google GenAI SDK also has streaming request methods (used internally by generateContentStream) that are not overridden. This means streaming Gemini calls — a common pattern for chat applications — are completely invisible to Braintrust tracing.
For comparison, both the OpenAI and Anthropic instrumentations in this repo handle streaming via SSE detection and chunk accumulation in their respective TracingHttpClient implementations.
Upstream sources
- Google GenAI Java SDK: https://github.com/googleapis/java-genai — streaming is a core feature, with
generateContentStreamavailable since early versions. The SDK is now at v1.46.0 (this repo pins to v1.18.0). - Gemini API streaming docs: https://ai.google.dev/gemini-api/docs/text-generation#generate-a-text-stream
Braintrust docs status
not_found— braintrust.dev/docs does not reference Google GenAI streaming instrumentation for Java. The Java SDK docs page redirects to the GitHub repo.
Local files inspected
braintrust-sdk/instrumentation/genai_1_18_0/src/main/java/com/google/genai/BraintrustApiClient.java— lines 186–312 (only non-streamingrequest/asyncRequestoverridden; no streaming method override)braintrust-sdk/instrumentation/genai_1_18_0/src/main/java/com/google/genai/BraintrustInstrumentation.java— wraps ApiClient in Client and service fields, no streaming awarenessbraintrust-sdk/instrumentation/genai_1_18_0/src/main/java/dev/braintrust/instrumentation/genai/v1_18_0/BraintrustGenAI.java— thin wrapper, delegates to BraintrustInstrumentationbraintrust-sdk/instrumentation/genai_1_18_0/src/test/java/dev/braintrust/instrumentation/genai/v1_18_0/BraintrustGenAITest.java— only tests sync and async non-streaming; no streaming tests exist
- Dominant language
- Java
- Stars
- 21
- Forks
- 5
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from braintrustdata/braintrust-sdk-java
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
All issues in braintrustdata/braintrust-sdk-java
Similar issues
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/flink-agents#1152 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
jenkinsci/blueocean-plugin#5417 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
objectionary/eo-graphs#75 ·