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
- Install traceAI VertexAI
pip install traceAI-vertexai
- 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
Built Distribution
File details
Details for the file traceai_vertexai-0.1.7.tar.gz
.
File metadata
- Download URL: traceai_vertexai-0.1.7.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
4a1e920c5b280a598b35faef2856730e4acac92af14540b6469c821c5b5ca945
|
|
MD5 |
0ac671e057a39cc369e395be89d93ea1
|
|
BLAKE2b-256 |
d72ddbb2d309a8b59df59443b5496d9b044df90657d8d754e39fd9d14b03a92a
|
File details
Details for the file traceai_vertexai-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: traceai_vertexai-0.1.7-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
0499b83c3c9a588deef59e1b8dfefbab53bad8313b982f15b288bb6f7876183f
|
|
MD5 |
d81d4e9f1de38bf5b16d2f14f1e05ae7
|
|
BLAKE2b-256 |
ff85d385c36e1990d6a43d86e4fd71386f975f06a424faa98d2c1e5872be9daa
|