Skip to content

[bot] Gemini Live API (real-time bidirectional streaming) not instrumented #114

@braintrust-bot

Description

@braintrust-bot

Summary

The Google GenAI Go SDK (google.golang.org/genai) exposes a Live API (client.Live.Connect()) for real-time bidirectional streaming via WebSocket. This repo does not instrument it at all. Braintrust documents Live API tracing support for Python, TypeScript, and Java, making Go the only SDK without coverage for this surface.

What is missing

Instrumentation for the genai Live API session lifecycle:

  • client.Live.Connect() — establishes a WebSocket session with a model
  • session.SendClientContent() — sends turn-based text/content
  • session.SendRealtimeInput() — sends real-time audio/video chunks
  • session.SendToolResponse() — responds to model-initiated tool calls
  • session.Receive() — receives server messages (ServerContent, ServerToolCall, ServerGoAway, etc.)

The current trace/contrib/genai/ integration works by wrapping http.RoundTripper, which only captures HTTP-based calls (generateContent, streamGenerateContent, embedContent, batchEmbedContents). The Live API uses WebSocket transport (github.com/gorilla/websocket) and bypasses the HTTP middleware entirely.

A new instrumentation approach would be needed — likely wrapping the *genai.Session or hooking into the LiveConnectConfig — to trace Live API interactions, capture tool calls during live sessions, and record token usage.

Note: The Live API is marked Preview in the Go SDK's doc comments, meaning it may have breaking changes. However, it is already GA in Gemini's Python and JavaScript SDKs and is actively documented by both Google and Braintrust.

Braintrust docs status

supported — The Braintrust Gemini integration docs state: "Braintrust also traces the Google GenAI interactions API, including the Live API exposed through client.aio.live.connect()." This confirms Live API tracing is a recognized Braintrust capability, but it is only available in non-Go SDKs today.

Upstream sources

Local repo files inspected

  • trace/contrib/genai/tracegenai.go — router only matches HTTP endpoints (:generateContent, :streamGenerateContent, :embedContent, :batchEmbedContents)
  • trace/contrib/genai/generatecontent.go — HTTP RoundTripper-based instrumentation
  • trace/contrib/genai/embedcontent.go — HTTP RoundTripper-based instrumentation
  • trace/contrib/genai/orchestrion.yml — auto-instrumentation wraps HTTPClient in ClientConfig, no Live API hook
  • examples/internal/genai/main.go — no Live API example
  • go.mod — depends on google.golang.org/genai (Live API is available in this module)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions