skillfed

opentelemetry-instrumentation-google-genai

OpenTelemetry

opentelemetry-instrumentation-google-genai v1.0b1 1.7M downloads/30d#3,661 on PyPI28
Permissive license Apache-2.0 Active released

What it is and what it does

This package wraps the Google GenAI SDK with OpenTelemetry instrumentation to automatically capture observability data from GenAI operations. It emits trace spans for calls like generate_content and embed_content, records prompts and responses as events/logs, and aggregates metrics describing GenAI activity—all following OpenTelemetry's GenAI semantic conventions. The instrumentation works by patching the SDK's client methods, so once you call instrument() it traces all subsequent GenAI operations without requiring changes to your application code.

The package is still experimental and has known defects documented in TODOS.md that block full stability. It supports Python 3.10 through 3.14 and integrates with the standard OpenTelemetry ecosystem (opentelemetry-api, opentelemetry-instrumentation, and related packages). You can optionally capture message content and GenerateContentConfig parameters via environment variables, and uninstrument clients when needed.

Use it for:

  • Monitor GenAI API calls in production by emitting traces to your OpenTelemetry backend (e.g., Jaeger, Datadog, New Relic).
  • Debug GenAI application behavior by capturing prompts, responses, and tool calls as span events and logs.
  • Aggregate metrics on GenAI usage (request counts, latencies, token consumption) for cost and performance analysis.
  • Correlate GenAI operations with other application traces to understand end-to-end request flow.
  • Audit GenAI interactions by recording message content and configuration parameters when enabled.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Adds OpenTelemetry instrumentation to the Google GenAI SDK, automatically emitting trace spans, events, and metrics for GenAI operations like generate_content, embed_content, and interactions.create.

Yes, with conditions. Install if you are already using OpenTelemetry in your application and need observability into Google GenAI SDK calls. The low install friction and permissive license make it a straightforward addition. However, be aware it is experimental with known blockers to stability—review TODOS.md before production use and expect potential API or behavior changes in future releases.

Install

opentelemetry-instrumentation-google-genai on PyPI

pip

pip install opentelemetry-instrumentation-google-genai

uv

uv add opentelemetry-instrumentation-google-genai

poetry

poetry add opentelemetry-instrumentation-google-genai

Installing opentelemetry-instrumentation-google-genai

Before you install

Low friction install with five runtime dependencies, all from the OpenTelemetry ecosystem. Active maintenance as of 2026-08-14 with recent release history; however, marked experimental with known defects listed in TODOS.md that are blockers to stability.

License in practice

Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most production environments.

Quickstart

pip install opentelemetry-instrumentation-google-genai

from opentelemetry.instrumentation.google_genai import GoogleGenAiSdkInstrumentor
from google.genai import Client

GoogleGenAiSdkInstrumentor().instrument()
client = Client()
response = client.models.generate_content(
    model="gemini-1.5-flash-002",
    contents="Write a short poem on OpenTelemetry."
)

Requires Python 3.10 or later; assumes OpenTelemetry tracing, logging, and metrics are already configured in your application.

Verify before relying

  • Completeness of instrumentation coverage for all Google GenAI SDK operations beyond generate_content, embed_content, and interactions.create.
  • Behavior and correctness of automatic function calling span nesting under generate_content spans.
  • Performance impact of instrumentation on GenAI SDK operations at scale.

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 5 — opentelemetry-api, opentelemetry-instrumentation, opentelemetry-semantic-conventions, opentelemetry-util-genai, wrapt
Maintenance actively maintained — 32 days since the last release
Last repo commit
First released
Downloads 1,678,224/month — #3,661 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: opentelemetry_instrumentation_google_genai-1.0b1-py3-none-any.whl

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

opentelemetry google genai instrumentationtrace genai sdk operationsgoogle gemini telemetryllm observability instrumentationgenai span metrics eventsgoogle genai monitoringsemantic conventions genai
observabilitygenaiinstrumentation

More Monitoring packages

tqdm

Wraps any iterable to display a real-time…

copyleft · top 100 on PyPI

opentelemetry-semantic-conventions

Provides generated Python code for…

permissive · top 100 on PyPI

opentelemetry-sdk

Provides the reference implementation of the…

permissive · top 100 on PyPI

opentelemetry-api

Provides the abstract API and interfaces for…

permissive · top 100 on PyPI

opentelemetry-exporter-otlp-proto-http

Exports OpenTelemetry observability data to an…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation

Provides automatic instrumentation commands and…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation-openai-v2

Automatically traces and logs OpenAI API calls…

permissive · top 5,000 on PyPI

opentelemetry-util-genai

Provides standardized instrumentation utilities…

permissive · top 5,000 on PyPI

opentelemetry-semantic-conventions-ai

Provides OpenTelemetry semantic conventions and…

permissive · top 1,000 on PyPI

loongsuite-util-genai

Extends OpenTelemetry's GenAI semantic…

permissive · top 5,000 on PyPI

openinference-instrumentation-google-genai

Automatically instruments Google GenAI SDK…

permissive · top 15,000 on PyPI

opentelemetry-instrumentation-voyageai

Automatically captures and traces Voyage AI API…

permissive · top 5,000 on PyPI

opentelemetry-instrumentation-groq

Automatically captures traces of Groq SDK API…

permissive · top 5,000 on PyPI

google-genai

Python SDK for integrating Google's Gemini…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation-aiokafka

Adds distributed tracing instrumentation to…

permissive · top 5,000 on PyPI

newrelic-telemetry-sdk

Sends custom metrics, events, logs, and…

permissive · top 5,000 on PyPI