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

Distributed request tracing #4718

Open
fjetter opened this issue Apr 20, 2021 · 2 comments
Open

Distributed request tracing #4718

fjetter opened this issue Apr 20, 2021 · 2 comments

Comments

@fjetter
Copy link
Member

fjetter commented Apr 20, 2021

I frequently find myself in a position where I need to answer questions like: "Who triggered this coroutine? Why was this coroutine triggered?", "Was this triggered by a remote call via a stream handler or due to some internal mechanics? If it was remote, who was it?". Is this the result of a cascade of tasks or was this an isolated request?

Most, if not all of these questions can be answered by different debugging techniques, starting from print statements or logging with some context information or by using a debugger. With the heavy usage of asyncio these debugging techniques have their limits and are also not straight forward to setup.

We started adding keywords like cause or reason to some functions, e.g. Worker.release_key which adds a free text field which can be optionally used to attach some context information. This hasn't been used consistently through the code base (as you can see we even have two different kwargs for the same thing in this method, one of them is not used, guess which?)

In a microservice world, this problem has been solved by distributed tracing. Oversimplified, this works by attaching a unique ID to every request and include said ID to subsequently spawned requests, etc. This allows one to correlated the initial trigger of a cascade of events and helps one to understand why and how certain things are happening.

I'm wondering if we can benefit from something like this in our distributed context as well, in particular regarding the administration work scheduler, worker, nanny, etc. perform.

If this is considered useful, I'm wondering if we should come up with our own definition for such metadata or adhere to some available tooling. If there is tooling, what would be appropriate?

Any thoughts or previous experience on this topic?

@mrocklin
Copy link
Member

mrocklin commented Apr 20, 2021 via email

@fjetter
Copy link
Member Author

fjetter commented Apr 20, 2021

my recollection is that cause= in some cases refers to another key.

Indeed. That makes things just much worse since it is sometimes used as a task key with actual semantic meaning and sometimes just as added context information.


we started adding more structured logging, like the transitions log,

Yes, I think the important bit here is the structured logging part. Structuring this information and storing it somewhere would allow something similar to story but for coroutines. I would be thrilled to see this as a library but I couldn't find much other than the full blown "distributed request tracing" frameworks for webservices. This feels like a rather common problem with async services and I'd be surprised if we were the first stumbling over this. Maybe we are, then it's probably fine to build something ourselves...

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