Skip to content

Instrumentation for Gemini via Google GenAIClient library#14

Merged
Andrew Kent (realark) merged 1 commit into
mainfrom
ark/gemini-instrumentation
Nov 25, 2025
Merged

Instrumentation for Gemini via Google GenAIClient library#14
Andrew Kent (realark) merged 1 commit into
mainfrom
ark/gemini-instrumentation

Conversation

@realark

@realark Andrew Kent (realark) commented Nov 20, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@realark Andrew Kent (realark) changed the title Ark/gemini instrumentation Instrumentation for Gemini via Google GenAIClient library Nov 20, 2025
@realark Andrew Kent (realark) added the enhancement New feature or request label Nov 20, 2025
@realark Andrew Kent (realark) force-pushed the ark/gemini-instrumentation branch 6 times, most recently from eed887d to 53685c4 Compare November 21, 2025 21:50
@realark Andrew Kent (realark) marked this pull request as ready for review November 21, 2025 22:07
Comment thread src/main/java/com/google/genai/BraintrustApiClient.java
var requestJson = JSON_MAPPER.readValue(requestBody, Map.class);

// Extract metadata fields
for (String field :

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my recommendation is to pass the literal input and output to the span. at rest it'll look liek

Image

(ref)

you may find that the ui will automatically render java produced spans automatically

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree, I'd much rather do that (or even better just send the entire request/response body and let the backend sort it out)

I think we need to update the backend to support otel here? I tried just sending the input contents directly on both braintrust.input and braintrust.input_json but the BE doesn't recognize that as an LLM message (I just get raw json/yaml views)

}

span.setAttribute(
"braintrust.input_json", JSON_MAPPER.writeValueAsString(inputJson));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know that it'll be a little different since we're using otel ingestion, but it should be the same thing if we just make sure the input is literal input and so on.

@realark

Copy link
Copy Markdown
Collaborator Author

Talked offline: plan is to update the backend to support parsing gemini messages. Once that is in place I'll update this instrumentation to use that simpler approach, but in the meantime I'm going to merge this in to get gemini support into the SDK.

@realark Andrew Kent (realark) merged commit c76aa52 into main Nov 25, 2025
1 check passed
@realark Andrew Kent (realark) deleted the ark/gemini-instrumentation branch November 25, 2025 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants