2026-11-05 · 8 min read
Observability for Serverless: Tracing Lambda with X-Ray and OpenTelemetry
Serverless breaks traditional monitoring, there's no host to watch and execution is fragmented. How to get real observability with distributed tracing, structured logs, and OTel.

Observability for Serverless: Tracing Lambda with X-Ray and OpenTelemetry
Serverless quietly breaks the monitoring habits you built on servers. There's no host to SSH into, no long-lived process to attach a profiler to, and a single user request fans out across Lambda → SQS → Lambda → DynamoDB → API. When something is slow, "check the server" has no meaning. The answer is to lean hard on the three pillars, traces, logs, metrics, with distributed tracing as the star.
Why serverless is different
- No host metrics that matter. CPU/memory of a Lambda environment is mostly AWS's problem.
- Execution is fragmented and short-lived. A function runs for 200ms then vanishes: you can't attach to it after the fact.
- Everything is distributed. One logical operation crosses many services and async boundaries. The hard questions are "where did the time go across this whole chain?" and "which hop failed?"
Tracing answers exactly those questions, which is why it's the most valuable signal in serverless.
Distributed tracing with X-Ray
AWS X-Ray is the native option. It builds a service map of how requests flow through your functions and AWS services, and shows a timeline of where latency accumulates.
- Enable active tracing on the function (one setting / IaC flag).
- Instrument the SDK so downstream calls (DynamoDB, S3, HTTP) appear as subsegments:
from aws_xray_sdk.core import patch_all
patch_all() # auto-instruments boto3, requests, etc.
Now a trace shows the full path, API Gateway → Lambda → DynamoDB, with timing per hop, so a slow DynamoDB query or a chatty downstream call is obvious instead of hidden in an aggregate.
OpenTelemetry: the vendor-neutral path
X-Ray is great if you're all-in on AWS tooling. But if you want one instrumentation that works everywhere, X-Ray, Datadog, Grafana Tempo, Honeycomb, Jaeger, use OpenTelemetry (OTel).
The AWS Distro for OpenTelemetry (ADOT) ships as a Lambda layer. You instrument with the OTel SDK once and export traces to whatever backend you choose; switching backends becomes a config change, not a re-instrumentation. This is the future-proof choice and pairs with your existing observability stack (Tempo/Grafana) so serverless traces sit beside your container traces.
Don't forget propagation across async boundaries
The classic serverless tracing failure: the trace breaks at the queue. When Lambda A puts a message on SQS/SNS/EventBridge and Lambda B picks it up, the trace context must travel with the message or you get two disconnected traces instead of one end-to-end view.
- Propagate trace context in message attributes (X-Ray and OTel both support this; ADOT/X-Ray handle a lot automatically for native AWS services).
- Verify your async hops actually stitch together in the service map, test it, don't assume it.
Structured logs, correlated to traces
Logs still matter; just make them useful:
- Log JSON, not strings: so CloudWatch Logs Insights can query fields.
- Include the trace/request ID in every log line: then you can jump from a slow trace straight to its logs. This correlation is the single biggest quality-of-life upgrade in serverless debugging.
- Powertools for AWS Lambda (Python/Node/Java/.NET) gives you structured logging, tracing, and custom metrics with almost no boilerplate, use it.
Metrics that matter in serverless
Watch the things serverless can actually go wrong on:
- Errors and throttles: function errors, and
Throttleswhen you hit a concurrency limit. - Duration p99: cold starts and slow dependencies live in the tail, not the average (see Lambda performance).
- Concurrency: how close you are to reserved/account limits.
- Async failures: DLQ depth,
IteratorAgeon streams (are you falling behind?). - Business metrics via CloudWatch Embedded Metric Format (EMF): emit custom metrics straight from log output, no extra API calls.
The short version
- Serverless has no host to watch and fragments each request across services, tracing is the key signal.
- Use X-Ray for native AWS tracing, or OpenTelemetry (ADOT) to stay vendor-neutral.
- Propagate trace context across SQS/SNS/EventBridge or your traces break at the queue.
- Log structured JSON with the trace ID so logs and traces correlate; use Lambda Powertools.
- Watch errors, throttles, duration p99, concurrency, and async backlog, not host CPU.
Building observability that works for serverless and containers alike is part of my consulting work, reach out.