On Mar 1, 2021, at 12:51 PM, Robert DiFalco <robert.difalco@gmail.com> wrote:
Is this the right place to ask klein questions?
Absolutely, it's a Twisted org project.
I'm writing a metrics plugin for Klein and I can't figure out how to inject a metrics handler so that I can get route, path, duration, and status code. What I'm doing now sucks because Klein and twisted interact in complex ways on Failure and status codes. # Replace the klein _call with the metrics generating call _app._call = _callWithMetrics Rather than replace _call with my version of _call I was hoping there was a cleaner way to get the start and stop with the result code of a route invocation. Thoughts?
It sounds like you should contribute a patch that makes this an explicitly-supported pluggable entrypoint, rather than relying on a hack. No need to figure out a way to make it work with existing versions, the magic of open source is that you can change it :). Feel free to ping here when it's done to remind folks to do a review. -g