VoltAgent Integration via OpenTelemetry

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

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-http

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'

To log the traces to a specific project, you can add the projectName parameter to the OTEL_EXPORTER_OTLP_HEADERS environment variable:

$export OTEL_EXPORTER_OTLP_HEADERS='Authorization=<your-api-key>,Comet-Workspace=default,projectName=<your-project-name>'

You can also update the Comet-Workspace parameter to a different value if you would like to log the data to a different workspace.

Using Opik with VoltAgent

Set up OpenTelemetry instrumentation for VoltAgent:

1import { trace, SpanStatusCode } from "@opentelemetry/api";
2import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
3import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
4import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
5
6// Configure the OTLP exporter
7const otlpExporter = new OTLPTraceExporter();
8
9// Set up the tracer provider
10const provider = new NodeTracerProvider();
11provider.addSpanProcessor(new BatchSpanProcessor(otlpExporter));
12provider.register();
13
14// Your VoltAgent code will now automatically send traces to Opik
15import { Agent } from "@voltagent/core";
16
17const agent = new Agent();
18// ... agent configuration

Further improvements

If you have any questions or suggestions for improving the VoltAgent integration, please open an issue on our GitHub repository.