Instrument with traceAI Helpers
Future AGI’s traceAI library offers convenient abstractions to streamline your manual instrumentation process.
traceAI OTEL Tracing
Learn how to leverage traceAI OTEL tracing decorators and methods to instrument your functions, chains, agents, and tools with OpenTelemetry.
These utilities complement or replace standard OpenTelemetry instrumentation code, making the process more straightforward and efficient.
Installation
Ensure you have FI Instrumentation Library installed:
Setting Up Tracing
Initialize your tracing environment with the following setup:
Using your Tracer
The tracer object provides two main approaches for instrumentation:
1. Function Decoration
Use decorators to trace complete functions:
When using this method, the entire function execution will be visible as a Span in Future AGI. Function parameters and return values automatically populate input and output attributes, while the status is set automatically.
2. Code Block Tracing
Utilize context managers to trace specific code segments:
The code within this clause will be captured as a Span in Future AGI. Here the input, output, and status must be set manually.
This method is particularly useful when you need to monitor specific portions of your code rather than entire functions.
FI Span Kinds
FI Span Kinds denote the possible types of spans you might capture, and will be rendered different in the Future AGI UI.
The possible values are:
Span Kind | Use |
---|---|
CHAIN | General logic operations, functions, or code blocks |
LLM | Making LLM calls |
TOOL | Completing tool calls |
RETRIEVER | Retrieving documents |
EMBEDDING | Generating embeddings |
AGENT | Agent invocations - typically a top level or near top level span |
RERANKER | Reranking retrieved context |
UNKNOWN | Unknown |
GUARDRAIL | Guardrail checks |
EVALUATOR | Evaluators |
Chains
Using Context Managers
Using Decorators
Using JSON Output
Overriding Span Name
Agents
Using Context Managers
Using Decorators
Tools
Using Context Managers
Using Decorators
Overriding Tool Name
Additional Features
Suppress Tracing
Using Context Attributes
This guide demonstrates the comprehensive capabilities of Future AGI OTEL tracing decorators for instrumenting chains, agents, and tools.