We are running Actix 4.0 beta at my workplace and believe we are encountering an issue in one of our custom middlewares. I decided I wanted to add some trace spans from the
tracing library into the middleware in an attempt to get a better idea of what is going on, specifically regarding timing. However, I'm not sure the best way to do this.
Some options I have thought of:
1.) I could add a new span which covers the entirety of the
Service::call function we have implemented, which would extend to any futures awaited. This is super simple, but it also means that the span's timing would include the timing of the rest of the request inside of the middleware "onion", and so the timing doesn't really tell us about how much the specific middleware itself took. If the "inner" middleware is also traced then one could see the difference in the span timings, so if we took this option we would need to add more tracing elsewhere to see this difference.
2.) Add explicit "before" and "after" spans inside the middleware. IOW, create one span which lasts from the start of the function until the inner service's
call function is made, and then open another span for anything that occurs after the
call function's future has resolved. This gets us more of what we want (measurements about how long our middleware is actually taking).
3.) Something else? Does actix have some functionality to help with debugging middleware timing already? Does tracing have features to only concentrate to "pause" a span and continue later?