Skip to content

Set the serving backend as a span attribute on the Google client spans #287

Description

@maragubot

The Google client (clients/google) can run against either the Gemini API (BackendGemini) or Vertex AI (BackendVertexAI), selected via NewClientOptions.Backend. The google.chat_complete and google.embed spans record ai.model but not which backend served the request.

This matters most behind the robust wrapper. When a consumer registers a Gemini primary with a Vertex fallback, a fallover is only visible via ai.robust.completer_index (1 = the second completer). That index's meaning is encoded in registration order, far from the telemetry: it silently flips if the completers are reordered, and a human (or an MCP agent) reading a trace can't tell what index 1 means without going to read the wiring code.

Request

Have the Google client set the backend as a span attribute on both google.chat_complete and google.embed — the client already knows its Backend. Either:

  • ai.backend = gemini | vertexai (matches the existing ai.* namespace), or
  • the OTel-standard gen_ai.system.

Then fallback traffic is greppable by name, independent of completer registration order.

Note

This overlaps with #246 (renaming Vertex AI to Gemini Enterprise Agent Platform) — whatever naming lands there should be the attribute value here.


Filed via Claude Code: https://claude.ai/code/session_01SxCXEQU7DLKw6p9B7kJ5Ej

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions