Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.
Start 7-day trial →
⚡
← Courses
›
FastAPI Production
›
Module 6 · Real-World Patterns
›
Structured logs with request_id (contextvars)
quiz
95 / 105
🇺🇸
EN
▼
↗
Share
⋯
More
+100 XP
📋
Task
📖
Theory
🤖
AI Help
Task
📝 **Question:** Why contextvars for request_id? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
🎯 Quiz
Question
📝 **Question:** Why contextvars for request_id? 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
A
Just easier ergonomics — no real isolation guarantee across concurrent tasks.
B
Async-aware task-local storage — every logger reads it without threading through every function.
C
Required by FastAPI — `Depends` rejects loggers that read from any other source.
D
Faster than passing the id as a function argument because lookups skip the call stack.
Submit answer
💬 Discussion
Be the first to ask a question or share a tip.
Sign in
to join the discussion. Reading is free.
Loading discussion…