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

feat: support instrument stream under TreeRoot #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sticnarf
Copy link

@sticnarf sticnarf commented Dec 6, 2023

I want await-tree to track a request stream passed to tonic. But the root future of tonic is apparently not under our control.

let req_stream = async_stream! {
    while x {
        whatever_fut.instrument_await("y").await; // not under any tree
        yield z;
    }
};
tonic_client.stream_rpc(req_stream);

And it doesn't work to use a customized executor that wraps every future with a TreeRoot. (Flood of future polled in a different context as it was first polled and future is dropped in a different context as it was first poll).

So, the best we can do is create a TreeRoot for the stream:

tonic_client.stream_rpc(tree_root.instrument_stream(req_stream));

Copy link
Member

@BugenZhao BugenZhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

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

Successfully merging this pull request may close these issues.

2 participants