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-1.2.0.tar.gz.

File metadata

File hashes

Hashes for openinference_instrumentation_google_genai-1.2.0.tar.gz
Algorithm Hash digest
SHA256 de657299be7cf8a5ff8822ccc0177db04996f53041d9cc370528fa02f1bae164
MD5 bcfbf9a48c3f6160a217ed87cbbce798
BLAKE2b-256 371a48edbb59303416cf545284bf5c36547ec2cdb13d1a93752cbfbd71b3d8f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_google_genai-1.2.0.tar.gz:

Publisher: publish.yaml on Arize-ai/openinference

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for openinference_instrumentation_google_genai-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0a755033b87d7ccfce69bd4a6a36a35c75eebb8196e9f6a2c1ec90de908c9d4
MD5 78717bd0391da174faeb57c512a49b3d
BLAKE2b-256 feb2b4f1628e267188581a7074efe27b51d2357efcd9203ff4f62a4a9507e4e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_google_genai-1.2.0-py3-none-any.whl:

Publisher: publish.yaml on Arize-ai/openinference

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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