How to access response body from custom middleware



I am creating custom middleware to handle datadog apm tracing. I want to intercept responses and turn the response body into an error that can be passed on to datadog, but I do not see a way to access the response body based solely upon the context. I see that there is a provided body dump middleware that allows access to the response body, but I want to avoid splitting this tracing logic between 2 separate pieces of middleware. Is there a better way to accomplish this goal?