Correlate Logs and Traces
Distributed tracing captures the timing and context of each request as it flows through your application and connected systems. Logs provide detailed insights into your application’s behavior at specific points in time. Together, they offer comprehensive visibility into both the broader request flow and granular application state.
When you correlate logs with traces, debugging becomes more efficient. Instead of investigating logs and traces separately, you can jump directly from an error log to its corresponding trace to understand the full context—what led to the error, how long each step took, and where the bottleneck occurred.
Vercel correlates logs with distributed traces automatically. When a request is traced using OpenTelemetry, Vercel automatically enriches any logs generated from your code with the following correlation identifiers:
traceId
- The trace identifier.spanId
- The span identifier.
The correlation happens automatically and does not require code changes:
console.log('User logged in', { userId: 123 });
We enrich logs with the trace and span identifiers.
- Correlation only applies to logs generated from user code during traced requests
- We do not correlate build-time logs with traces
Was this helpful?