Skip to content

registry exit: decrement local span ref only #3331

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

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

Conversation

davidhewitt
Copy link

Motivation

Fixes #3223

Solution

From my understanding, it's sufficient for Registry::exit just to call self.try_close() and do local bookkeeping:

  • The attempt to use the thread dispatcher leads directly to the issues observed in tracing & tracing-subscriber have a design defect I believe #3223, and
  • I don't think it's correct to call try_close on the whole Layer stack at this point anyway, a span being exited is not yet ready to close. All that is needed is to decrement the reference count within the current registry.

I've added a test which spawns a thread and enters (and exits, and drops) a span created on a dispatcher not registered to that thread.

Before this patch, the test fails with the span never being closed (because there is no thread dispatcher when the span is exited, and so a reference is leaked in Registry::exit).

With this patch, the bookkeeping demonstrated in the test seems correct to me.

@davidhewitt
Copy link
Author

Note that changing Registry::exit to just call self.try_close() is also presumably a performance gain, because there is no need to dispatch through TLS on each span exit.

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.

tracing & tracing-subscriber have a design defect I believe
1 participant