Grokking Concurrency in Python
Vote

0% completed

​

Request Context and Observability

When a service handles several requests at the same time, their log lines arrive mixed together in one stream. A short label attached to every line that one request produces lets you pick that request's lines out of the stream (a request id; Harvest calls it a crawl id). With it, you can follow a slow request or an error from start to finish.

Passing the id by hand to every function that logs is impractical in a large program. Python's contextvars module stores the id once for each task instead.

Context Variables

**A context variable is a variable, created with `contextvars.ContextVar

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content