Grokking Concurrency in Go
0% completed
Context Values
How does a log line written five function calls away from the request handler show which request it belongs to? A server handles many requests at the same time, and their log lines are mixed together in one output. To find every line for one failing request, each line needs the request's ID, which is a short string assigned when the request arrives.
The function that writes the log line rarely has that ID. Adding a requestID parameter to every function between the handler and the logger would change dozens of signatures, many of them in libraries that know nothing about requests
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%