Description
Environment
actix-web 4.4.0
actix-web-lab 0.19.1
sentry-tracing 0.31.7
sentry-actix 0.31.6
Steps to Reproduce
- intercept incoming request with actix-web-lab middleware
- call
sentry::add_breadcrumb(incoming_request)
beforenext.call(req).await
- server executes logic ... error is thrown
- use
tracing::error!(...)
to capture error message - sentry reported error has no incoming request breadcrumb
Expected Result
Breadcrumb attached with the reported error.
Actual Result
Breadcrumb is missing.
Workaround
pass the incoming_request
breadcrumb in actix request extensions and sentry::add_breadcrumb
from within the request execution context ([middleware -> [ request ] ]
)
Notes
I suspect that the middleware uses a different Hub from the request:
Because actix is generally working with non sendable objects and highly concurrent this middleware creates a new hub per request. As a result many of the sentry integrations such as breadcrumbs do not work unless you bind the actix hub
(source)
We tried binding the current Hub inside middleware but it raises an issue with the ServiceRequest
which is not Send
.
Is there a way to attach this breadcrumb directly from middleware?