Skip to main content

OpenTelemetry VertexAI instrumentation (tapm edition)

Project description

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

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

tapm_instrumentation_vertexai-0.1b2.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

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

tapm_instrumentation_vertexai-0.1b2-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file tapm_instrumentation_vertexai-0.1b2.tar.gz.

File metadata

File hashes

Hashes for tapm_instrumentation_vertexai-0.1b2.tar.gz
Algorithm Hash digest
SHA256 5b83b28c84987ad41aab65d5694b7c5c3d958e759b105a827c59e022b4d5439a
MD5 d9835a8c5de7ad6f410efd669c34b570
BLAKE2b-256 c74f2166ef4b5924c1cda74f00907d4316acc1c2e712bfc6939cb64943d3a517

See more details on using hashes here.

File details

Details for the file tapm_instrumentation_vertexai-0.1b2-py3-none-any.whl.

File metadata

File hashes

Hashes for tapm_instrumentation_vertexai-0.1b2-py3-none-any.whl
Algorithm Hash digest
SHA256 25cb15a718c35873b6c10891944e29aba096a15892c43da1bd2e0b882fc02bb1
MD5 da48d84733bd9e71b606b09b901f2093
BLAKE2b-256 1bf63496f54f7e9d767c4f34e4b1862e777412a18acba7bf242240b944ad5196

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