LangWatch
Integrate Kern with LangWatch to send traces and gain insights into your agent's performance.
Integrating Kern with LangWatch
LangWatch provides a robust platform for tracing and monitoring AI model calls. By integrating Kern with LangWatch, you can utilize OpenInference instrumentation to send traces and gain insights into your agent's performance.
Prerequisites
-
Install Dependencies
Ensure you have the necessary packages installed:
1uv pip install langwatch kern-ai openai openinference-instrumentation-kern-ai -
Setup LangWatch Account
- Sign up for an account at LangWatch.
- Obtain your API key from the LangWatch dashboard.
-
Set Environment Variables
Configure your environment with the LangWatch API key:
1export LANGWATCH_API_KEY=<your-api-key>
Sending Traces to LangWatch
-
Example: Using LangWatch with OpenInference
This example demonstrates how to instrument your Kern agent with OpenInference and send traces to LangWatch.
1import langwatch2import os34from kern.agent import Agent5from kern.models.openai import OpenAIResponses6from openinference.instrumentation.kern import AgnoInstrumentor78# Initialize LangWatch and instrument Kern9langwatch.setup(instrumentors=[AgnoInstrumentor()])1011# Create and configure your Kern agent12agent = Agent(13 name="A helpful AI Assistant",14 model=OpenAIResponses(id="gpt-5.2"),15 tools=[],16 instructions="You are a helpful AI Assistant.",17 debug_mode=True,18)1920# Use the agent21agent.print_response("Tell me a joke.")The AgnoInstrumentor automatically captures all Kern agent activity. All traces will be sent to your LangWatch dashboard without requiring manual OpenTelemetry configuration.
Notes
- Environment Variables: Ensure your environment variables are correctly set for the API key.
- Automatic Instrumentation: The LangWatch SDK handles OpenTelemetry configuration automatically when you use
langwatch.setup(). - Additional Features: LangWatch supports capturing RAG data, metadata, attributes, evaluations, and guardrails. Visit the LangWatch documentation for more information.
By following these steps, you can effectively integrate Kern with LangWatch, enabling comprehensive observability and monitoring of your AI agents.