A step-by-step guide to instrumenting AI agents with OpenTelemetry GenAI semantic conventions entirely locally, without sending data to the cloud. Covers deploying an OpenTelemetry Collector and Jaeger via Docker Compose, instrumenting a Node.js AI agent with GenAI span attributes (gen_ai.system, gen_ai.request.model, token usage), structuring parent-child span hierarchies for multi-step agent flows, and building a React dashboard to visualize model usage, token costs, and latency from Jaeger's API. Includes troubleshooting for common pitfalls like protocol mismatches, BatchSpanProcessor flush issues, and API key security.

15m read timeFrom sitepoint.com
Post cover image
Table of contents
How to Instrument AI Agents with OpenTelemetry GenAI LocallyTable of ContentsWhy Observability for AI Agents Is DifferentWhat Are the OpenTelemetry GenAI Semantic Conventions?Architecture Overview: Fully Local Observability StackSetting Up the Local OpenTelemetry Collector and JaegerInstrumenting a Node.js AI Agent with OpenTelemetry GenAI AttributesAdding a React Dashboard for Real-Time Agent MetricsImplementation Checklist: Your Complete ReferenceCommon Pitfalls and TroubleshootingWhat Comes Next
359 Impressions