Skip to main content

traceAI-google-generativeai

OpenTelemetry instrumentation for the legacy Google Generative AI Python SDK (google-generativeai, imported as google.generativeai). Applications on the newer google-genai SDK use traceAI-google-genai instead.

Installation

pip install traceAI-google-generativeai

Usage

import google.generativeai as genai
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from traceai_google_generativeai import GoogleGenerativeAIInstrumentor

tracer_provider = register(project_name="my-project", project_type=ProjectType.OBSERVE)
GoogleGenerativeAIInstrumentor().instrument(tracer_provider=tracer_provider)

genai.configure(api_key="...")
model = genai.GenerativeModel("gemini-1.5-flash")
print(model.generate_content("Say hello").text)

With FI_INSTRUMENTATIONS unset, the zero-code agent enables it automatically when google.generativeai is importable.

What is traced

Call Span Kind
GenerativeModel.generate_content, with or without stream=True GenerateContent LLM
GenerativeModel.generate_content_async, with or without stream=True AsyncGenerateContent LLM
ChatSession.send_message / send_message_async one GenerateContent span per turn, chat history as input LLM
embed_content / embed_content_async EmbedContent / AsyncEmbedContent EMBEDDING

count_tokens is not traced.

LLM spans carry the model, generation parameters (gen_ai.request.parameters, temperature, top-p, top-k, max tokens, stop sequences), the system instruction, input and output messages, tool definitions, tool calls with their JSON arguments, token usage (input, output, total, cached), finish reasons and the aggregated response. Streaming spans end when the stream is consumed, record gen_ai.server.time_to_first_token (milliseconds) and the aggregated output; a stream that is dropped part-way ends with gen_ai.response.incomplete. Failed calls re-raise unchanged and mark the span as an error. Embedding spans record the input texts and the vector size, never the vectors. Inline binary parts are noted by MIME type and size, never copied.

Privacy

Content goes through the TraceConfig masker. hide_inputs / FI_HIDE_INPUTS removes prompts, system instructions, tool definitions, function results and embedding texts; hide_outputs / FI_HIDE_OUTPUTS removes responses and tool-call arguments.

Supported versions

google-generativeai 0.8.0 and later (tested on 0.8.x), Python 3.10 to 3.13. embed_content imported with from google.generativeai import embed_content before instrumenting keeps the original function; import it after instrumenting or call it through genai.

Metadata

Release files for traceAI-google-generativeai 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traceAI-google-generativeai 0.1.0
File Size Uploaded Provenance Actions
traceai_google_generativeai-0.1.0.tar.gz 9.6 kB Without provenance Details for traceai_google_generativeai-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for traceAI-google-generativeai 0.1.0
File Interpreter ABI Platform Actions
traceai_google_generativeai-0.1.0-py3-none-any.whl Python 3 none any Details for traceai_google_generativeai-0.1.0-py3-none-any.whl

Total release size: 20.5 kB

Release files / traceai_google_generativeai-0.1.0.tar.gz

Download URL traceai_google_generativeai-0.1.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
afac491508e99ac2f4c9ead52bb04ca596a8dbb2f272f2893b11c82ebdf5f838
BLAKE2b-256 checksum
How to use checksums
64305b4f7205b3a2a9417c718d4b22b0f0981af8222416e32418d0d8825bcee9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / traceai_google_generativeai-0.1.0-py3-none-any.whl

Download URL traceai_google_generativeai-0.1.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a658dc752caea950b9eafacde359ba0e00630499cc9d1c3524d7bd377090a61
BLAKE2b-256 checksum
How to use checksums
a247134db38ac294c0888450237bbaad4bb1e80dfcbed650fd11e1b4e39e512b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for traceAI-google-generativeai 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page