Skip to content

Conversation

zeebo
Copy link
Member

@zeebo zeebo commented Dec 15, 2020

Consider code like

func Foo(ctx context.Context) (err error) {
    defer mon.Task()(&ctx)(&err)
    stream := Bar(ctx)
    stream.RPC()
    stream.RPC()
    return nil
}

func Bar(ctx context.Context) (Stream) {
    defer mon.Task()(&ctx)(nil)
    return newStream(ctx)
}

where the Stream type internally stores the context passed to it for the RPC invocations. Arguably, this code doesn't use contexts correctly because the RPCs should be passed the ctx, but this is how gRPC works.

Because the Stream context is a child of the Bar context that is exited, the RPC invocations, if monitored, will be considered orphaned. Instead, this change makes it so that they are parented by Foo.

The tree of spans will become something closer to a DAG, but it should be the case that there is only one reachable path to a child at a time through non-done spans.

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.

1 participant