Script Valley
Debugging: A Systematic Approach
Strategic Logging and Observability/Assessment

Practice & Assessment

Test your understanding of Strategic Logging and Observability

Multiple Choice Questions

5
1

Which log level should you use when a payment processor returns an unexpected response code but your system handles it by retrying?

2

What is the primary purpose of a correlation ID in logging?

3

A log entry reads: level error, msg Payment failed. What critical information is missing?

4

You have a 4-second API response time. Your code has three steps: auth check, DB query, JSON transform. What is the correct first action?

5

What does this command produce: cat app.log | jq -r 'select(.level == "error") | .msg' | sort | uniq -c | sort -rn

Coding Challenges

1
1

Add Production-Ready Logging to a Broken Service

A provided Node.js Express route handler processes orders but has no logging. Add structured logging using pino that covers: a correlation ID generated per request, entry and exit logs for the main handler, per-step timing for DB query and payment charge operations, an error log with full context on failure, and a WARN log for the case where an order amount exceeds $10,000. Input: provided route handler file. Output: the same file with logging added. Time estimate: 25 minutes.

Medium

Mini Project

1

Log-Driven Bug Diagnosis Report

Given a provided JSON log file from a simulated e-commerce API (containing INFO, WARN, and ERROR entries with correlation IDs, user IDs, order IDs, and timing fields), use jq or grep to: find all errors and group them by message, identify the three correlation IDs associated with errors, retrieve the full execution trace for each failing request, identify the last successful operation before each failure, determine the root cause for each of the three failures, and write a structured bug report for each. Submit the jq queries used and the three bug reports.

Medium