Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pypi

This library allows tracing LLM requests and logging of messages made by the VertexAI Python API library.

Installation

If your application is already instrumented with OpenTelemetry, add this package to your requirements.

pip install opentelemetry-instrumentation-vertexai

If you don’t have an VertexAI application, yet, try our examples.

Check out zero-code example for a quick start.

Usage

This section describes how to set up VertexAI instrumentation if you’re setting OpenTelemetry up manually. Check out the manual example for more details.

Instrumenting all clients

When using the instrumentor, all clients will automatically trace VertexAI chat completion operations. You can also optionally capture prompts and completions as log events.

Make sure to configure OpenTelemetry tracing, logging, and events to capture all telemetry emitted by the instrumentation.

from opentelemetry.instrumentation.vertexai import VertexAIInstrumentor
from vertexai.generative_models import GenerativeModel

VertexAIInstrumentor().instrument()


vertexai.init()
model = GenerativeModel("gemini-1.5-flash-002")
response = model.generate_content("Write a short poem on OpenTelemetry.")

Enabling message content

Message content such as the contents of the prompt, completion, function arguments and return values are not captured by default. To capture message content as log events, set the environment variable OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT to true.

Uninstrument

To uninstrument clients, call the uninstrument method:

from opentelemetry.instrumentation.vertexai import VertexAIInstrumentor

VertexAIInstrumentor().instrument()
# ...

# Uninstrument all clients
VertexAIInstrumentor().uninstrument()

References

Metadata

Release files for tapm-instrumentation-vertexai 0.1b2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tapm-instrumentation-vertexai 0.1b2
File Size Uploaded
tapm_instrumentation_vertexai-0.1b2.tar.gz 22.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tapm-instrumentation-vertexai 0.1b2
File Interpreter ABI Platform
tapm_instrumentation_vertexai-0.1b2-py3-none-any.whl Python 3 none any Details

Total release size: 39.4 kB

Release files / tapm_instrumentation_vertexai-0.1b2.tar.gz

Download URL tapm_instrumentation_vertexai-0.1b2.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5b83b28c84987ad41aab65d5694b7c5c3d958e759b105a827c59e022b4d5439a
BLAKE2b-256 checksum
How to use checksums
c74f2166ef4b5924c1cda74f00907d4316acc1c2e712bfc6939cb64943d3a517
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release files / tapm_instrumentation_vertexai-0.1b2-py3-none-any.whl

Download URL tapm_instrumentation_vertexai-0.1b2-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25cb15a718c35873b6c10891944e29aba096a15892c43da1bd2e0b882fc02bb1
BLAKE2b-256 checksum
How to use checksums
1bf63496f54f7e9d767c4f34e4b1862e777412a18acba7bf242240b944ad5196
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.1b2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page