Skip to main content

OpenInference VertexAI Instrumentation

Project description

OpenInference Google VertexAI Instrumentation

Python auto-instrumentation library for VertexAI SDK and the Google Cloud AI Platform. Traces are fully OpenTelemetry compatible and can be sent to any OpenTelemetry collector for viewing, such as Arize Phoenix.

pypi

Installation

pip install -Uqqq openinference-instrumentation-vertexai

Quickstart

Install openinference-instrumentation-vertexai and arize-phoenix.

pip install -U \
    openinference-instrumentation-vertexai \
    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.

python -m phoenix.server.main serve

Instrumenting vertexai is simple.

from openinference.instrumentation.vertexai import VertexAIInstrumentor
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)))

VertexAIInstrumentor().instrument(tracer_provider=tracer_provider)

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

import vertexai
from vertexai.generative_models import GenerativeModel

vertexai.init(location="us-central1")
model = GenerativeModel("gemini-1.5-flash")

print(model.generate_content("Why is sky blue?"))

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_vertexai-0.1.10.tar.gz.

File metadata

File hashes

Hashes for openinference_instrumentation_vertexai-0.1.10.tar.gz
Algorithm Hash digest
SHA256 db146622d57f10008e4d543a5ed1ebfce2f1b57d58226ad29e0063e0bafd1627
MD5 c8052ddb2fa8d1a28e1896b49f1be86e
BLAKE2b-256 ee1ba49eb9ff3e99b6b7afe06ca3911e86d3dc3d2be803e7e5880c28e8db31fb

See more details on using hashes here.

File details

Details for the file openinference_instrumentation_vertexai-0.1.10-py3-none-any.whl.

File metadata

File hashes

Hashes for openinference_instrumentation_vertexai-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d07161888a3461c5bdd184fac34a6835256be312cf7a960290c39c15be3a319c
MD5 c9b40e47e6da8ad3b402f8090a7f4160
BLAKE2b-256 9b7413ac23cf59d5d0fe4e6a3b6df8acb736ba2a4fbed0497923f9b3f7daa32b

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