Observability for VoltAgent with Opik
VoltAgent is an agent framework designed to simplify the creation and management of AI agents with built-in support for tool usage, memory management, and multi-agent coordination. It provides a flexible architecture for building production-ready AI agent systems.
VoltAgent's primary advantage is its modular design that allows developers to easily create, customize, and deploy AI agents with comprehensive tool integration and memory capabilities.
Getting started
Section titled “Getting started”To use the VoltAgent integration with Opik, you will need to have VoltAgent and the required OpenTelemetry packages installed:
npm install @voltagent/core @opentelemetry/api @opentelemetry/sdk-trace @opentelemetry/exporter-trace-otlp-httpEnvironment configuration
Section titled “Environment configuration”Configure your environment variables based on your Opik deployment:
If you are using Opik Cloud, you will need to set the following environment variables:
export OTEL_EXPORTER_OTLP_ENDPOINT=https://www.comet.com/opik/api/v1/private/otel
export OTEL_EXPORTER_OTLP_HEADERS='Authorization=<your-api-key>,Comet-Workspace=default'If you are using an Enterprise deployment of Opik, you will need to set the following environment variables:
export OTEL_EXPORTER_OTLP_ENDPOINT=https://<comet-deployment-url>/opik/api/v1/private/otel
export OTEL_EXPORTER_OTLP_HEADERS='Authorization=<your-api-key>,Comet-Workspace=default'If you are self-hosting Opik, you will need to set the following environment variables:
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:5173/api/v1/private/otelUsing Opik with VoltAgent
Section titled “Using Opik with VoltAgent”Set up OpenTelemetry instrumentation for VoltAgent:
import { trace, SpanStatusCode } from "@opentelemetry/api";
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
// Configure the OTLP exporter
const otlpExporter = new OTLPTraceExporter();
// Set up the tracer provider
const provider = new NodeTracerProvider();
provider.addSpanProcessor(new BatchSpanProcessor(otlpExporter));
provider.register();
// Your VoltAgent code will now automatically send traces to Opik
import { Agent } from "@voltagent/core";
const agent = new Agent();
// ... agent configurationFurther improvements
Section titled “Further improvements”If you have any questions or suggestions for improving the VoltAgent integration, please open an issue on our GitHub repository.