Skip to main content

VertexAI OpenTelemetry Integration

Overview

This integration provides support for using OpenTelemetry with the VertexAI framework. It enables tracing and monitoring of applications built with VertexAI.

Installation

  1. Install traceAI VertexAI
pip install traceAI-vertexai
  1. Install VertexAI SDK
pip install vertexai

Set Environment Variables

Set up your environment variables to authenticate with FutureAGI

import os

os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = GOOGLE_APPLICATION_CREDENTIALS

Quickstart

Register Tracer Provider

Set up the trace provider to establish the observability pipeline. The trace provider:

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="vertexai_app"
)

Configure VertexAI Instrumentation

Instrument the VertexAI client to enable telemetry collection. This step ensures that all interactions with the VertexAI SDK are tracked and monitored.

from traceai_vertexai import VertexAIInstrumentor

VertexAIInstrumentor().instrument(tracer_provider=trace_provider)

Create VertexAI Components

Set up your VertexAI client with built-in observability.

import vertexai
from vertexai.generative_models import FunctionDeclaration, GenerativeModel, Part, Tool

vertexai.init(
    project="project_name",
)

# Describe a function by specifying its schema (JsonSchema format)
get_current_weather_func = FunctionDeclaration(
    name="get_current_weather",
    description="Get the current weather in a given location",
    parameters={
        "type": "object",
        "properties": {
            "location": {
                "type": "string",
                "description": "The city and state, e.g. San Francisco, CA",
            },
            "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
        },
        "required": ["location"],
    },
)

# Tool is a collection of related functions
weather_tool = Tool(function_declarations=[get_current_weather_func])

# Use tools in chat
chat = GenerativeModel("gemini-1.5-flash", tools=[weather_tool]).start_chat()

if __name__ == "__main__":
    for response in chat.send_message(
        "What is the weather like in Boston?", stream=True
    ):
        print(response)
    for response in chat.send_message(
        Part.from_function_response(
            name="get_current_weather",
            response={"content": {"weather": "super nice"}},
        ),
        stream=True,
    ):
        print(response)

Metadata

Release files for traceAI-vertexai 0.1.10

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

Source distribution (sdist)

Source distribution for traceAI-vertexai 0.1.10
File Size Uploaded
traceai_vertexai-0.1.10.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for traceAI-vertexai 0.1.10
File Interpreter ABI Platform
traceai_vertexai-0.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 25.3 kB

Release files / traceai_vertexai-0.1.10.tar.gz

Download URL traceai_vertexai-0.1.10.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c4dc3e80d1475bdb2d2e01e16b5ce652ce0731dfd0a37bdb7426282f73f8cb91
BLAKE2b-256 checksum
How to use checksums
14ffe295098d2897c966f46e1a403219ddb259ee55a06131c21b7a8f96b762d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / traceai_vertexai-0.1.10-py3-none-any.whl

Download URL traceai_vertexai-0.1.10-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4096bc8005ee3ac0e0c295b742d1ce3891089cd048aa597019c48d4943ce936
BLAKE2b-256 checksum
How to use checksums
c9f9bd1d1f0ea6ae3744cbce1523b595403d9f773d0962d748eee04a9d40fd26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.10 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

3 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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