Tracing Kit
OpenTelemetry-style distributed traces. Visualize every span from prompt → tool → response.
Total: 2400msSpans: 11Errors: 0
Integration Code
import { createTracer, JaegerExporter, ConsoleExporter } from 'agent-tools-kit/observability'
const tracer = createTracer({
serviceName: 'my-agent',
exporters: [
new JaegerExporter({ endpoint: 'http://localhost:14268/api/traces' }),
new ConsoleExporter(), // for local dev
],
// Auto-instrument all agent operations
autoInstrument: ['llm', 'tools', 'memory', 'guardrails'],
// Sampling: 100% in dev, 10% in prod
sampler: process.env.NODE_ENV === 'production'
? { type: 'probabilistic', probability: 0.1 }
: { type: 'always_on' },
})
// Automatic tracing via middleware
agent.use(tracer.middleware())
// Manual spans for custom operations
const result = await tracer.span('custom-operation', async (span) => {
span.setAttribute('custom.key', 'value')
const data = await fetchExternalData()
span.addEvent('data_fetched', { count: data.length })
return processData(data)
})
// Access trace context for correlation
const traceId = tracer.currentTraceId()
logger.info('Processing request', { traceId })