Skip to main content

OpenTelemetry instrumentation for Vertex AI

Project description

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)

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

traceai_vertexai-0.1.10.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

traceai_vertexai-0.1.10-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file traceai_vertexai-0.1.10.tar.gz.

File metadata

  • Download URL: traceai_vertexai-0.1.10.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for traceai_vertexai-0.1.10.tar.gz
Algorithm Hash digest
SHA256 c4dc3e80d1475bdb2d2e01e16b5ce652ce0731dfd0a37bdb7426282f73f8cb91
MD5 ab86580e7bdb847013740cac1f78ef8c
BLAKE2b-256 14ffe295098d2897c966f46e1a403219ddb259ee55a06131c21b7a8f96b762d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceai_vertexai-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for traceai_vertexai-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 c4096bc8005ee3ac0e0c295b742d1ce3891089cd048aa597019c48d4943ce936
MD5 ec8f9c4dd9d7d16c8c3e28ef1673af1b
BLAKE2b-256 c9f9bd1d1f0ea6ae3744cbce1523b595403d9f773d0962d748eee04a9d40fd26

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