Explain how to produce meaningful logs, correlation IDs, request IDs, and event metadata that can support debugging across many short-lived executions.
Structured telemetry is what makes short-lived serverless executions diagnosable after they disappear. A function may run for only a few hundred milliseconds, but the logs and metadata it emits can still tell operators which request it handled, which tenant it affected, which event triggered it, which dependency call failed, and whether the failure is isolated or systemic.
Plain text logs are rarely enough in a serverless platform. There are too many small executions and too many parallel paths. Logs need structure so they can be filtered, aggregated, and correlated across services and invocations.
flowchart LR
A["Request or event"] --> B["Function"]
B --> C["Structured log entry"]
C --> D["Central log store"]
D --> E["Search by correlation ID"]
What to notice:
Useful log entries usually include:
The anti-pattern is to log generic strings like “processing started” or “failed to handle request” with no identifying context. Those lines multiply quickly and explain nothing.
1{
2 "level": "info",
3 "message": "invoice generation completed",
4 "requestId": "req-91f2",
5 "correlationId": "corr-7b55",
6 "workflow": "monthly-billing-close",
7 "tenantId": "tenant-204",
8 "invoiceId": "inv-881",
9 "durationMs": 143,
10 "attempt": 1
11}
1export function logInfo(message: string, fields: Record<string, unknown>) {
2 console.log(JSON.stringify({
3 level: "info",
4 message,
5 timestamp: new Date().toISOString(),
6 ...fields,
7 }));
8}
What this demonstrates:
In a monolithic request path, one trace can often explain the whole interaction. In serverless systems, the path may cross:
That makes correlation IDs essential. Each downstream component should either preserve the current correlation ID or derive one child context in a consistent way.
Structured logging should not become “dump the entire payload.” Sensitive fields, large objects, and raw secrets create security risk and noisy telemetry. The strongest logs include the identity of the object and the outcome of the step, not a blind serialization of everything the function saw.
A payment workflow spans an API, a queue, two functions, and a reconciliation step. Operators can see that failures happened, but they cannot reconstruct the path of one customer request across those components. What is missing first?
The stronger answer is consistent correlation context and structured logs, not more log volume. Without a shared identifier and stable fields across hops, the platform produces telemetry that is large but not connected.