opentelemetry-python-contrib icon indicating copy to clipboard operation
opentelemetry-python-contrib copied to clipboard

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

Open michaelsafyan opened this issue 9 months ago • 0 comments
trafficstars

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:

  • https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3256

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

michaelsafyan avatar Feb 11 '25 18:02 michaelsafyan