Extract metrics and Sentry to middleware
Add extra context for Sentry exceptions