Skip to content
bossfight
.dev
learn
problems
guides
bosses
roadmap
practice
Interview mode
Live coding rounds with a clock
Gauntlet
Tiny problems back to back: spot it, code it
Quiz
Quick checks on every topic
Which technique?
Name the pattern before you code
Estimation drills
Back-of-envelope numbers for system design
By company
Work through one company's set
Mock assessments
Timed company sets, no hints
Codebase rounds
Fix and extend a real repo
progress
sign in
Search
Ctrl K
menu
Learn
Learn (step by step)
Guides
Roadmap
Practice
Problems
Interview mode
Gauntlet
Quiz
Which technique?
Estimation drills
By company
Mock assessments
Codebase rounds
Play
Boss fights
You
Progress
Sign in
~/rounds
Metrics pipeline
medium
60 min
Python
Stripe Bug Squash-style
Google code comprehension-style
1
The same minute, three rows
2
Build a feature
3
Make it fast
repo
metrics/
__init__.py
aggregate.py
buckets.py
cli.py
endpoints.py
export.py
parse.py
pipeline.py
tests/
visible/
test_pipeline.py
logs.py
README.md
README.md
read-only
# metrics Turns our API servers' access logs into per-minute metrics for the dashboard. A log line looks like this: 2026-09-14T21:59:58.120+02:00 web-3 GET /api/orders/88?full=1 200 123ms timestamp (ISO 8601 with its UTC offset; no offset means UTC), host, method, path, HTTP status, latency. Servers log in their own local time: the Frankfurt hosts use `+02:00`, the Virginia ones `-04:00`, some use `Z`. The log collector merges every host into one file **in time order**. metrics/parse.py parse_line(): one line -> Event, or None for junk metrics/endpoints.py endpoint_for(): /api/orders/88?full=1 -> /api/orders/:id metrics/buckets.py minute_of(): which UTC minute an event belongs to metrics/aggregate.py Stats per (minute, endpoint) metrics/export.py the CSV the dashboard loads metrics/pipeline.py run(lines, out): parse, aggregate, write CSV metrics/cli.py python -m metrics.cli access.log > metrics.csv The CSV has one row per UTC minute and endpoint, sorted by minute, then endpoint: minute,endpoint,count,errors,avg_ms,max_ms 2026-09-14T19:59Z,/api/orders/:id,412,3,87.4,1630 `errors` counts 5xx responses. Lines that don't parse are skipped and counted. Run the tests with `python -m pytest` (or press Run in the browser).
esc