Skip to content

Feature Request: automatic instrumentation for Google GenAI SDK (github.com/googleapis/python-genai). #3260

@michaelsafyan

Description

@michaelsafyan

What problem do you want to solve?

It would be ideal to have automatic instrumentation for the github.com/googleapis/python-genai (PyPi: google-genai) package.

Describe the solution you'd like

A subpackage like instrumentation-genai/opentelemetry-instrumentation-vertexai, except for google-genai.

I have already drafted an initial PR for this that covers a portion of the API surface here:

If submitted, logical next steps would be:

  1. Adding support for streaming and async variants of generate_content
  2. Registering the package with opentelemetry-contrib-instrumentations
  3. Defining OTel SemConv for request/response information not currently defined in OTel SemConv
  4. Adding instrumentation/recording for these additional attributes of the request/response
  5. Extending the logic to also cover other methods (e.g. generating embeddings)

Describe alternatives you've considered

Work with owners of github.com/googleapis/python-genai to bake-in the instrumentation in that repository.

I have privately discussed this alternative with the owners and believe, based on that conversation, that it would be better for the time being to pursue instrumentation in the Open Telemetry Python Contrib repository, instead.

Additional Context

No response

Would you like to implement a fix?

Yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions