opentelemetry-instrumentation-google-genai
OpenTelemetry
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-genaiuv
uv add opentelemetry-instrumentation-google-genaipoetry
poetry add opentelemetry-instrumentation-google-genaiInstalling 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
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
opentelemetry-instrumentation-openai-v2Automatically traces and logs OpenAI API calls…
permissive · top 5,000 on PyPI
opentelemetry-util-genaiProvides standardized instrumentation utilities…
permissive · top 5,000 on PyPI
opentelemetry-semantic-conventions-aiProvides OpenTelemetry semantic conventions and…
permissive · top 1,000 on PyPI
loongsuite-util-genaiExtends OpenTelemetry's GenAI semantic…
permissive · top 5,000 on PyPI
openinference-instrumentation-google-genaiAutomatically instruments Google GenAI SDK…
permissive · top 15,000 on PyPI
opentelemetry-instrumentation-voyageaiAutomatically captures and traces Voyage AI API…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-groqAutomatically captures traces of Groq SDK API…
permissive · top 5,000 on PyPI
google-genaiPython SDK for integrating Google's Gemini…
permissive · top 1,000 on PyPI
opentelemetry-instrumentation-aiokafkaAdds distributed tracing instrumentation to…
permissive · top 5,000 on PyPI
newrelic-telemetry-sdkSends custom metrics, events, logs, and…
permissive · top 5,000 on PyPI