Instrumentors

Auto-instrument frameworks, clean up, and instrument other languages.

Each framework has its own instrumentor package. Install the one for your framework and call .instrument().

# Pattern is the same for every framework:
from traceai_<framework> import <Framework>Instrumentor
<Framework>Instrumentor().instrument(tracer_provider=trace_provider)
PackageFrameworkInstrumentor class
traceai-openaiOpenAIOpenAIInstrumentor
traceai-anthropicAnthropicAnthropicInstrumentor
traceai-google-genaiGoogle GenAIGoogleGenAIInstrumentor
traceai-vertexaiVertex AIVertexAIInstrumentor
traceai-bedrockAWS BedrockBedrockInstrumentor
traceai-mistralaiMistral AIMistralAIInstrumentor
traceai-groqGroqGroqInstrumentor
traceai-litellmLiteLLMLiteLLMInstrumentor
traceai-cohereCohereCohereInstrumentor
traceai-ollamaOllamaOllamaInstrumentor
traceai-deepseekDeepSeekDeepSeekInstrumentor
traceai-togetherTogether AITogetherInstrumentor
traceai-fireworksFireworks AIFireworksInstrumentor
traceai-cerebrasCerebrasCerebrasInstrumentor
traceai-xaixAI / GrokXAIInstrumentor
traceai-vllmvLLMVLLMInstrumentor
traceai-portkeyPortkeyPortkeyInstrumentor
traceai-huggingfaceHuggingFaceHuggingFaceInstrumentor
PackageFrameworkInstrumentor class
traceai-langchainLangChain / LangGraphLangChainInstrumentor
traceai-llamaindexLlamaIndexLlamaIndexInstrumentor
traceai-crewaiCrewAICrewAIInstrumentor
traceai-openai-agentsOpenAI Agents SDKOpenAIAgentsInstrumentor
traceai-autogenMicrosoft AutoGenAutoGenInstrumentor
traceai-smolagentsHuggingFace SmolAgentsSmolAgentsInstrumentor
traceai-google-adkGoogle Agent Dev KitGoogleADKInstrumentor
traceai-claude-agent-sdkClaude Agent SDKClaudeAgentSDKInstrumentor
traceai-pydantic-aiPydantic AIPydanticAIInstrumentor
traceai-strandsAWS Strands AgentsStrandsInstrumentor
traceai-agnoAgnoAgnoInstrumentor
traceai-beeaiIBM BeeAIBeeAIInstrumentor
traceai-haystackHaystackHaystackInstrumentor
traceai-dspyDSPyDSPyInstrumentor
traceai-guardrailsGuardrails AIGuardrailsInstrumentor
traceai-instructorInstructorInstructorInstrumentor
traceai-mcpModel Context ProtocolMCPInstrumentor
PackageFrameworkInstrumentor class
traceai-pipecatPipecatPipecatInstrumentor
traceai-livekitLiveKitLiveKitInstrumentor
PackageFrameworkInstrumentor class
traceai-pineconePineconePineconeInstrumentor
traceai-chromadbChromaDBChromaDBInstrumentor
traceai-qdrantQdrantQdrantInstrumentor
traceai-weaviateWeaviateWeaviateInstrumentor
traceai-milvusMilvusMilvusInstrumentor
traceai-lancedbLanceDBLanceDBInstrumentor
traceai-mongodbMongoDBMongoDBInstrumentor
traceai-pgvectorpgvectorPgVectorInstrumentor
traceai-redisRedisRedisInstrumentor

Cleanup

To remove instrumentation (useful in tests or serverless cleanup):

OpenAIInstrumentor().uninstrument()
TraceAI.shutdown();  // Flushes remaining spans and shuts down
TraceAI.Shutdown();  // Flushes remaining spans and shuts down

For per-framework setup guides with full examples, see the Auto-Instrumentation docs.

Other Languages

The tables above show Python packages. TypeScript, Java, and C# have their own instrumentation libraries:

TypeScript packages follow the @traceai/<framework> pattern. All use OpenTelemetry’s registerInstrumentations().

import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { OpenAIInstrumentation } from "@traceai/openai";
import { AnthropicInstrumentation } from "@traceai/anthropic";
import { LangChainInstrumentation } from "@traceai/langchain";
import { PineconeInstrumentation } from "@traceai/pinecone";

registerInstrumentations({
  tracerProvider,
  instrumentations: [
    new OpenAIInstrumentation(),
    new AnthropicInstrumentation(),
    new LangChainInstrumentation(),
    new PineconeInstrumentation(),
  ],
});

40+ packages available including all LLM providers, frameworks, and vector DBs from the Python list, plus @traceai/vercel for Vercel/Next.js and @traceai/mastra.

Java uses the Traced* wrapper pattern. Each integration wraps the native client:

// LLM Providers
TracedOpenAIClient traced = new TracedOpenAIClient(openAIClient);
TracedAnthropicClient traced = new TracedAnthropicClient(anthropicClient);
TracedBedrockRuntimeClient traced = new TracedBedrockRuntimeClient(bedrockClient);
TracedGenerativeModel traced = new TracedGenerativeModel(model);  // Google GenAI
TracedOllamaAPI traced = new TracedOllamaAPI(ollamaAPI);
TracedCohereClient traced = new TracedCohereClient(cohereClient);
TracedWatsonxAI traced = new TracedWatsonxAI(watsonxClient);

// Vector Databases
TracedPineconeIndex traced = new TracedPineconeIndex(index, "my-index");
TracedQdrantClient traced = new TracedQdrantClient(qdrantClient);
TracedMilvusClient traced = new TracedMilvusClient(milvusClient);
TracedChromaCollection traced = new TracedChromaCollection(collection);
TracedMongoVectorSearch traced = new TracedMongoVectorSearch(collection);
TracedRedisVectorSearch traced = new TracedRedisVectorSearch(jedis);
TracedSearchClient traced = new TracedSearchClient(searchClient);    // Azure Search
TracedPgVectorStore traced = new TracedPgVectorStore(connection);
TracedElasticsearchClient traced = new TracedElasticsearchClient(esClient);

// Framework integrations
TracedChatLanguageModel traced = new TracedChatLanguageModel(model, tracer, "openai");  // LangChain4j
TracedChatModel traced = new TracedChatModel(chatModel, tracer, "openai");              // Spring AI
TracedKernel traced = new TracedKernel(kernel, tracer);                                 // Semantic Kernel

Maven coordinates: com.github.future-agi.traceAI:traceai-java-<provider>:v1.0.0

C# uses manual tracing via FITracer. No auto-instrumentation wrappers yet - use the convenience methods (Llm(), Chain(), Agent(), Tool()) to create spans around your calls.

// Wrap any LLM call
var response = tracer.Llm("openai-call", span =>
{
    span.SetAttribute(SemanticConventions.GenAiRequestModel, "gpt-4o");
    span.SetInput(prompt);
    var result = CallOpenAI(prompt);
    span.SetOutput(result);
    span.SetTokenCounts(inputTokens, outputTokens, totalTokens);
    return result;
});

Install: dotnet add package fi-instrumentation-otel

Was this page helpful?

Questions & Discussion