openinference-instrumentation-google-genai (original) (raw)

Project description

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

More Info

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

File details

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

File metadata

File hashes

Hashes for openinference_instrumentation_google_genai-0.1.2.tar.gz | Algorithm | Hash digest | | | ----------- | ---------------------------------------------------------------- | | | SHA256 | 8eec5bc7e3619ab501d33a62e7302fd990f5485c2141e6f5169ae73cfc901eba | | | MD5 | e4a5fee7d60d1ae693ebbbfb9052ae8a | | | BLAKE2b-256 | 7d87c730b40c0a67a6f2a01f60d2daf8fa4e1574a2a26f22d6167181add671ab | |

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openinference_instrumentation_google_genai-0.1.2-py3-none-any.whl | Algorithm | Hash digest | | | ----------- | ---------------------------------------------------------------- | | | SHA256 | 8725489c955cdebc89ea5815c3dfcea38f351e28792987b506706eecfaa37167 | | | MD5 | 1c3d557916041142f06b4710f2350d28 | | | BLAKE2b-256 | 9d5fd261bd7f61f8282eb00bc2a1ab18bea23c049f831468a0d24a933cabc9b3 | |

See more details on using hashes here.