Distributed Tracing
End-to-end tracing for complete visibility into your AI agent execution flows.
Creating Traces
Tracing is captured via OpenTelemetry. Configure the provider once at startup
(for example in an instrumentation.ts that is imported before the rest of your
app), then wrap your code with observe or startActiveObservation.
typescript
// instrumentation.ts — imported first, runs once at startup
const provider = new NodeTracerProvider({
spanProcessors: [
new AntsPlatformSpanProcessor({
publicKey: process.env.ANTS_PLATFORM_PUBLIC_KEY,
secretKey: process.env.ANTS_PLATFORM_SECRET_KEY,
baseUrl: "https://api.agenticants.ai",
}),
],
});
provider.register();
setAntsPlatformTracerProvider(provider);
typescript
await startActiveObservation("customer-support-agent", async () => {
updateActiveTrace({
input: userQuery,
metadata: { userId: "user_123", sessionId: "session_abc" },
});
// ... your agent logic; nested observations attach to this trace
});
The same flow in Python uses the @observe() decorator and the configured
client singleton:
python
from ants_platform import AntsPlatform, observe, get_client
AntsPlatform(
public_key="pk_...", # or set ANTS_PLATFORM_PUBLIC_KEY
secret_key="sk_...", # or set ANTS_PLATFORM_SECRET_KEY
host="https://api.agenticants.ai",
)
@observe(name="customer-support-agent")
def handle_query(user_query: str):
client = get_client()
client.update_current_trace(
input=user_query,
metadata={"userId": "user_123", "sessionId": "session_abc"},
)
# ... your agent logic; nested spans attach to this trace
return result
# flush before the process exits (e.g. short-lived scripts)
get_client().flush()
Trace Visualization
View complete execution paths:
code
Trace: customer-support-query (2.5s)
├─ validate-input (10ms)
├─ retrieve-context (200ms)
├─ llm-inference (2.0s)
└─ format-output (290ms)