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

Support async+thread context propagation in FastAPI #89

Open
garyd203 opened this issue May 24, 2022 · 0 comments
Open

Support async+thread context propagation in FastAPI #89

garyd203 opened this issue May 24, 2022 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@garyd203
Copy link
Owner

garyd203 commented May 24, 2022

When FastAPI runs a non-async dependency or handler, it puts it into an internal thread pool so that the async execution doesn't get blocked. I'm pretty sure that the trace context doesn't get propagated into that thread pool (see Sean's problem in #88), which is obviously undesirable. It'd be nice if this worked seamlessly instead.

We probably need a new context (or just extend the existing no-bugs AsyncContext in xraysink) which can hook into FastAPI's specific non-async dispatch in order to add the trace context to those calls. This work could be fairly large!

Possibly related, but probably different piece of work: Support calling an instrumented sync function from async code (eg. see aws/aws-xray-sdk-python#164 (comment))

encode/starlette#1258 may be a helpful starting point

@garyd203 garyd203 added bug Something isn't working enhancement New feature or request labels May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant