Skip to main content

OpenInference Google GenAI Instrumentation

Project description

OpenInference Google GenAI Instrumentation

Python auto-instrumentation library for GenAI SDK. Traces are fully OpenTelemetry compatible and can be sent to any OpenTelemetry collector for viewing, such as Arize Phoenix.

Installation

pip install -Uqqq openinference-instrumentation-google-genai

Quickstart

Install openinference-instrumentation-google-genai and arize-phoenix.

pip install -U \
    openinference-instrumentation-google-genai \
    arize-phoenix \
    opentelemetry-sdk \
    opentelemetry-exporter-otlp \
    "opentelemetry-proto>=1.12.0"

Start the phoenix server so that it is ready to receive traces. The phoenix server runs entirely on your machine and does not send data over the internet.

phoenix serve

Instrumenting genai is simple.

from openinference.instrumentation.google_genai import GoogleGenAIInstrumentor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

endpoint = "http://127.0.0.1:4317"
tracer_provider = TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))

GoogleGenAIInstrumentor().instrument(tracer_provider=tracer_provider)

Now, all calls by generate_content are instrumented and can be viewed in the phoenix UI.

Progress

This instrumentation is a work in progress

  • parse messages and invocation
  • capture tool definitions

More Info

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

Built Distribution

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

File details

Details for the file openinference_instrumentation_google_genai-0.1.3.tar.gz.

File metadata

File hashes

Hashes for openinference_instrumentation_google_genai-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0bf367777fd7982ab4442c20d51700d7200b14c8a0e37003dcd0bfdf27d13418
MD5 8d2fbdb7147dd001381bd7f405e838da
BLAKE2b-256 94cc72825ead3a84d1b562b9d296b55145ab257de68a069b83a6b168df2077d8

See more details on using hashes here.

File details

Details for the file openinference_instrumentation_google_genai-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for openinference_instrumentation_google_genai-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 53ee7051694710876c4b3cdbc5cb4d0c8fc856aecc919467e237bfb04db5e014
MD5 b41c8dc0e31b84ede80e69db9c14ae8d
BLAKE2b-256 5fb73479460645123c93d2c51b8eaa7ff5259dd2cc66111fbf9c809a196bdaad

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