Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add a breadcrumb from actix-web middleware #624

Open
ferologics opened this issue Nov 7, 2023 · 0 comments
Open

Unable to add a breadcrumb from actix-web middleware #624

ferologics opened this issue Nov 7, 2023 · 0 comments

Comments

@ferologics
Copy link

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

  1. intercept incoming request with actix-web-lab middleware
  2. call sentry::add_breadcrumb(incoming_request) before next.call(req).await
  3. server executes logic ... error is thrown
  4. use tracing::error!(...) to capture error message
  5. 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?

@szokeasaurusrex szokeasaurusrex self-assigned this Nov 16, 2023
@szokeasaurusrex szokeasaurusrex removed their assignment Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants