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

reparent orphaned spans to grandparents #28

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

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