Skip to main content

OpenTelemetry instrumentation for Google Gen AI

Project description

Google Gen AI OpenTelemetry Integration

Overview

This integration provides support for using OpenTelemetry with the Google Gen AI framework. It enables tracing and monitoring of applications built with Google Gen AI.

Installation

  1. Install traceAI Google Gen AI
pip install traceAI-google-genai

Set Environment Variables

Set up your environment variables to authenticate with FutureAGI

import os

os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY

Quickstart

Register Tracer Provider

Set up the trace provider to establish the observability pipeline. The trace provider:

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="google_genai_project"
)

Configure Google Gen AI Instrumentation

Instrument the Google Gen AI client to enable telemetry collection. This step ensures that all interactions with the Google Gen AI SDK are tracked and monitored.

from traceai_google_genai import GoogleGenAIInstrumentor

GoogleGenAIInstrumentor().instrument(tracer_provider=trace_provider)

Make a request

Set up your Google Gen AI client with built-in observability.

from google import genai
from google.genai import types

client = genai.Client(vertexai=True, project="your_project_name", location="global")

content = types.Content(
    role="user",
    parts=[
        types.Part.from_text(text="Hello how are you?"),
    ],
)
response = client.models.generate_content(
    model="gemini-2.0-flash-001", contents=content
)

print(response)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traceai_google_genai-0.1.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traceai_google_genai-0.1.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file traceai_google_genai-0.1.0.tar.gz.

File metadata

  • Download URL: traceai_google_genai-0.1.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_google_genai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dad755684d38dd4cfc69926629eb8ee8c389446fe6e0e2a15caff433ba737717
MD5 ecd936b72040a9246fce77424d21c390
BLAKE2b-256 326e566fbe2971d6f63aee47c9b5272cfb8647e442b098ef9ed1b2088a2f2fd7

See more details on using hashes here.

File details

Details for the file traceai_google_genai-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for traceai_google_genai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5fdd0cf5661b1f45270cbc92f01148eaa082b794696065d9ed3526723667e1dd
MD5 137533058b41c42ef2f652622c3cfbfd
BLAKE2b-256 0d74c6ae4c5c6081b24375a128e351d69b621a0e5793574cd80ad2b14f06e802

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page