The Three Pillars: Metrics, Logs, and Traces
Observability is built on three complementary data types. Metrics are numerical measurements sampled over time: request rate, error rate, p50 and p99 response latency, CPU and memory utilisation, LLM token usage per request, and cost per inference. Metrics are efficient to store and query at scale and are the basis for alerting on quantitative thresholds. Logs are timestamped records of discrete events: a request arrived, a database query ran, an LLM API call was made with specific parameters, an error was thrown. Logs provide the detail to understand what happened during a specific request or incident. Traces are distributed traces that track a single request as it flows through multiple services, functions, and external API calls. A trace for an AI product request shows the Next.js server action, the vector database query, the LLM API call, and the response transformation as a connected timeline with timing for each step. Together, the three pillars provide different lenses on the same system: metrics tell you something is wrong, logs tell you what the specific event was, and traces show you where in the request flow the problem occurred.
LLM-Specific Observability
Standard application observability tools do not capture the AI-specific signals that matter for LLM-powered products. LLM observability requires tracking prompt inputs and outputs over time to detect quality degradation, token usage and cost per user session to understand economics, latency distributions broken down by model and prompt length, error rates by error type including rate limit errors, timeouts, and content filter rejections, and model output quality signals such as user acceptance rate or thumbs-up or thumbs-down feedback. Dedicated LLM observability platforms including LangSmith, LangFuse, Helicone, and PromptLayer are designed specifically for this. They capture prompt templates with variable substitutions, LLM API call parameters, response content, token counts, and latency in a searchable log that lets you trace a specific user's AI interaction end to end. These platforms typically also support prompt version tracking, which is the LLM equivalent of code version control: you can see which prompt version was in use for a given set of requests and roll back to a previous version if a new prompt degrades quality.
Implementing Metrics for AI Products
The core metrics to implement for an AI product fall into two categories: infrastructure metrics and AI-specific business metrics. Infrastructure metrics include application request rate, error rate, p50 and p99 latency, database query duration, cache hit rate, and serverless function cold start rate. These are collected by your cloud provider's native monitoring (CloudWatch, GCP Monitoring) or by an agent from a managed observability platform such as Datadog, New Relic, or Grafana Cloud. AI-specific metrics include LLM API call rate and latency, token usage per request broken down by prompt and completion tokens, LLM API error rate by error type, inference cost per user session, AI feature engagement rate (the percentage of users who interact with AI-powered features), and output quality signals from user feedback. Emit these custom metrics from your application code using your monitoring platform's SDK. Define alert thresholds for critical metrics: alert if LLM error rate exceeds 5% over a 5-minute window, if p99 LLM latency exceeds 30 seconds, or if cost per session exceeds a threshold that indicates runaway token usage.
Structured Logging for AI Workflows
Structured logging means emitting log events as JSON objects with consistent fields rather than as unstructured text strings. For AI products, structured logs enable filtering and analysis in ways that free-text logs do not. When your application makes an LLM API call, log a structured event that captures the user identifier (pseudonymised for GDPR compliance), the feature or prompt template used, the model called, the token counts, the latency, and whether the call succeeded. When a user provides quality feedback on an AI output, log a structured event with the output identifier and the feedback signal. These structured log events become a queryable dataset in your log management platform. You can query for all LLM calls that used prompt template X and returned outputs with a latency above 10 seconds, or all user feedback events where the rating was negative for a specific feature, identifying quality issues that aggregate metrics would not reveal. In the UK, remember that prompt content logs may contain personal data, requiring appropriate retention limits and access controls consistent with GDPR data minimisation principles.
Distributed Tracing for Multi-Step AI Workflows
Distributed tracing is particularly valuable for AI products with multi-step agentic workflows or RAG pipelines where understanding end-to-end request latency requires seeing how time is distributed across vector database queries, LLM calls, tool executions, and response transformations. OpenTelemetry is the open standard for distributed tracing instrumentation, supported by all major observability platforms including Datadog, Grafana Tempo, Honeycomb, and AWS X-Ray. Instrumenting your application with OpenTelemetry creates trace spans for each step in your AI workflow, linking them into a single trace with parent-child relationships. When a user reports that a specific request was slow, you can retrieve the trace for that request and see exactly how many seconds were spent in the vector database query versus the LLM API call versus your application code. LangChain and LlamaIndex both have OpenTelemetry instrumentation available or built-in callbacks that emit trace events. Integrating these with your tracing backend gives you AI workflow traces alongside standard application traces in the same observability platform.
Alerting and On-Call for AI Products
Observability data is only valuable if alerts are configured to notify the right people when important thresholds are crossed. For AI products, configure alerts at two levels. Service-level alerts catch hard failures: error rates above a threshold, service health check failures, LLM API connection errors, database unavailability. These should trigger immediate notification to whoever is on call. Quality-level alerts catch degradation that does not look like a hard failure: a slow increase in p99 latency, a drop in LLM API success rate from 99% to 95%, a rise in the rate of negative user feedback on AI outputs. These warrant investigation during business hours rather than at 3am. PagerDuty, OpsGenie, and Grafana OnCall integrate with observability platforms to route alerts to the appropriate channels and people. For early-stage AI product teams, a simpler setup of critical alerts to a Slack channel with clear severity labelling is sufficient. Avoid alert fatigue by calibrating thresholds carefully so that every alert represents something that genuinely requires attention.