Revision: https://github.com/atuinsh/atuin-ai-server/commit/63329e065dc73f2f6af8270928c003525c1befe1
Instead of diffing times, one can use :timer.tc/1 to track duration. Even better, one could use :telemetry.span/3 to track duration and publish a metric.
Instead of doing State.get/0 inside the body of each route, resolving the state can be moved to a separate plug invoked before routes are matched, and stored into a assign. This simplifies testing, as it removes state from the body of the route.