Guance Learn

Observability questions

Focused answers for definitions, architecture choices, troubleshooting, pricing, and evaluation.

Python programming and application logging
Explainer

Log uncaught exceptions in Python

Use sys.excepthook for top-level failures, threading.excepthook for worker threads, and explicit handling for functions and asynchronous tasks.

Python programming and application logging
Explainer

Measure elapsed time in Python

Compare Python timing functions, measure elapsed work with perf_counter, and avoid confusing nanosecond units with clock resolution.

Illustration of server operations and request logs
Explainer

Keep Nginx startup independent of upstream DNS availability

Avoid configuration-time hostname failures with runtime resolution, understand backup limits, and return a controlled maintenance response.

Python programming and application logging
Explainer

Pad strings and numbers with zeros in Python

Use zfill for signed strings, numeric format specifications for integers, and rjust or ljust when you need literal character padding.

Illustration of server operations and request logs
Explainer

Parse Nginx access logs for request analysis

Extract fields from combined access logs, count requests by status and second, and avoid misleading timing or time-window analysis.

Python programming and application logging
Explainer

How Python passes arguments to functions

Understand shared objects, local rebinding, mutable defaults, and shallow copies when passing values to Python functions.

Python programming and application logging
Explainer

Print literal braces in Python format strings

Escape braces in f-strings and str.format, combine literal braces with substitutions, and serialize JSON without hand-built templates.

Python programming and application logging
Explainer

Pretty-print JSON files and responses in Python

Format JSON with indentation, preserve Unicode, validate API responses, and use Python’s json.tool from the command line.

Python programming and application logging
Explainer

Print to standard error in Python

Send diagnostics to stderr with print or logging, keep them separate from stdout, and redirect each stream independently.

Python programming and application logging
Explainer

Print without a newline in Python

Control print endings with end, separate arguments with sep, and flush progress output when it would otherwise remain buffered.

Python programming and application logging
Explainer

Profile a Python script with cProfile

Find expensive functions with cProfile, sort saved statistics with pstats, and choose line profiling or timeit for more focused analysis.

Python programming and application logging
Explainer

Raise and re-raise exceptions in Python

Choose appropriate Python exception types, preserve causes with raise from, and re-raise failures without relying on assertions for input validation.