Tracing: OpenTelemetry SDK for Future AGI AI Apps
Set up OpenTelemetry tracing across Python, TypeScript, Java, and C#. Auto-instrument 45+ frameworks or create custom spans with FITracer.
register()sets up the tracer provider in two lines, all languages- Auto-instrument with
traceai-*packages (45+ frameworks) or create custom spans withFITracer - Context helpers attach session, user, metadata, and tags to all spans in a block
- TraceConfig controls privacy masking, PII redaction covers 6 data types automatically
The pattern is the same across all four languages: call register() once to set up the provider, then either auto-instrument your frameworks or use FITracer for custom spans. LLM calls, retrieval steps, and agent actions get captured as OpenTelemetry spans and sent to your dashboard.
Note
Requires FI_API_KEY and FI_SECRET_KEY in your environment. For conceptual background on traces, spans, and attributes, see the Tracing guide.
Quick Example
pip install fi-instrumentation-otel traceai-openaifrom fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from traceai_openai import OpenAIInstrumentor
# 1. Register the tracer provider
trace_provider = register(
project_name="my-project",
project_type=ProjectType.OBSERVE,
)
# 2. Instrument your framework
OpenAIInstrumentor().instrument(tracer_provider=trace_provider)
# 3. Use OpenAI as normal - all calls are now traced
import openai
client = openai.OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "What is Python?"}],
) npm install @traceai/openai @traceai/fi-core @opentelemetry/instrumentationimport { register, ProjectType } from "@traceai/fi-core";
import { OpenAIInstrumentation } from "@traceai/openai";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import OpenAI from "openai";
const tracerProvider = register({
projectName: "my-project",
projectType: ProjectType.OBSERVE,
});
registerInstrumentations({
tracerProvider,
instrumentations: [new OpenAIInstrumentation()],
});
const openai = new OpenAI();
const response = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello!" }],
}); <!-- For Spring Boot apps -->
<dependency>
<groupId>com.github.future-agi.traceAI</groupId>
<artifactId>traceai-spring-boot-starter</artifactId>
<version>v1.0.0</version>
</dependency>
<dependency>
<groupId>com.github.future-agi.traceAI</groupId>
<artifactId>traceai-java-openai</artifactId>
<version>v1.0.0</version>
</dependency>import ai.traceai.TraceAI;
import ai.traceai.TraceConfig;
import ai.traceai.openai.TracedOpenAIClient;
// Initialize from environment variables
TraceAI.initFromEnvironment();
// Wrap your client
TracedOpenAIClient tracedClient = new TracedOpenAIClient(openAIClient);
var response = tracedClient.createChatCompletion(params);Set FI_API_KEY, FI_SECRET_KEY, FI_BASE_URL, and FI_PROJECT_NAME as environment variables.
dotnet add package fi-instrumentation-otelusing FIInstrumentation;
using FIInstrumentation.Types;
var tracer = TraceAI.Register(opts =>
{
opts.ProjectName = "my-project";
opts.ProjectType = ProjectType.Observe;
});
// Create traced LLM calls with convenience methods
var result = tracer.Llm("openai-call", span =>
{
span.SetInput("What is C#?");
var response = CallOpenAI("What is C#?");
span.SetOutput(response);
return response;
});
TraceAI.Shutdown(); Related
Tracing Guide
Concepts, manual tracing, and per-framework setup guides.
Auto-Instrumentation
Setup guides for all 45+ supported frameworks.
Evaluations
Score traced outputs with 76+ metrics.
Datasets
Store test data and run batch evaluations.
Protect
Guard inputs and outputs with safety rules.
Simulation Testing
Test voice AI agents with simulated personas.
Questions & Discussion