Arize

Integrate Kern with Arize Phoenix to send traces and gain insights into your agent's performance.

Integrating Kern with Arize Phoenix

Arize Phoenix is a powerful platform for monitoring and analyzing AI models. By integrating Kern with Arize Phoenix, you can leverage OpenInference to send traces and gain insights into your agent's performance.

Prerequisites

  1. Install Dependencies

    Ensure you have the necessary packages installed:

    1uv pip install arize-phoenix openai openinference-instrumentation-kern-ai opentelemetry-sdk opentelemetry-exporter-otlp
  2. Setup Arize Phoenix Account

    • Create an account at Arize Phoenix.
    • Obtain your API key from the Arize Phoenix dashboard.
  3. Set Environment Variables

    Configure your environment with the Arize Phoenix API key:

    1export ARIZE_PHOENIX_API_KEY=<your-key>

Sending Traces to Arize Phoenix

  • Example: Using Arize Phoenix with OpenInference

This example demonstrates how to instrument your Kern agent with OpenInference and send traces to Arize Phoenix.

1import asyncio
2import os
3
4from kern.agent import Agent
5from kern.models.openai import OpenAIResponses
6from kern.tools.yfinance import YFinanceTools
7from phoenix.otel import register
8
9# Set environment variables for Arize Phoenix
10os.environ["PHOENIX_CLIENT_HEADERS"] = f"api_key={os.getenv('ARIZE_PHOENIX_API_KEY')}"
11os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "https://app.phoenix.arize.com"
12
13# Configure the Phoenix tracer
14tracer_provider = register(
15 project_name="kern-stock-price-agent", # Default is 'default'
16 auto_instrument=True, # Automatically use the installed OpenInference instrumentation
17)
18
19# Create and configure the agent
20agent = Agent(
21 name="Stock Price Agent",
22 model=OpenAIResponses(id="gpt-5.2"),
23 tools=[YFinanceTools()],
24 instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
25 debug_mode=True,
26)
27
28# Use the agent
29agent.print_response("What is the current price of Tesla?")

Now go to the phoenix cloud and view the traces created by your agent. You can visualize the execution flow, monitor performance, and debug issues directly from the Arize Phoenix dashboard.

arize-kern observability
Arize Phoenix Trace
  • Example: Local Collector Setup

For local development, you can run a local collector using

1phoenix serve
1import os
2
3from kern.agent import Agent
4from kern.models.openai import OpenAIResponses
5from kern.tools.yfinance import YFinanceTools
6from phoenix.otel import register
7
8# Set the local collector endpoint
9os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "http://localhost:6006"
10
11# Configure the Phoenix tracer
12tracer_provider = register(
13 project_name="kern-stock-price-agent", # Default is 'default'
14 auto_instrument=True, # Automatically use the installed OpenInference instrumentation
15)
16
17# Create and configure the agent
18agent = Agent(
19 name="Stock Price Agent",
20 model=OpenAIResponses(id="gpt-5.2"),
21 tools=[YFinanceTools()],
22 instructions="You are a stock price agent. Answer questions in the style of a stock analyst.",
23 debug_mode=True,
24)
25
26# Use the agent
27agent.print_response("What is the current price of Tesla?")

Notes

  • Environment Variables: Ensure your environment variables are correctly set for the API key and collector endpoint.
  • Local Development: Use phoenix serve to start a local collector for development purposes.

By following these steps, you can effectively integrate Kern with Arize Phoenix, enabling comprehensive observability and monitoring of your AI agents.