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

Fix span linking #4

Merged
merged 4 commits into from
Apr 29, 2024
Merged

Fix span linking #4

merged 4 commits into from
Apr 29, 2024

Conversation

ThomWright
Copy link
Owner

This took me quite a number of hours with the debugger to figure out.

The key parts are:

  • Spans can be cloned. Much like Arc, they have a reference count.
  • When a span gets dropped, an attempt will be made to close it. It will only close it if the ref count is zero.
  • Closing a span removes it from the Registry.
  • If you try to call span_a.follows_from(span_b_id) after span B has been closed, it will panic. Therefore, a Span with that ID must still be in scope.
  • If you call span_a.follows_from(span_b) then span B will be consumed (and hence dropped) and converted into an ID before being passed to the function. This ID will no longer refer to a valid span in the Registry.

The following both work:

  • Passing by reference: span_a.follows_from(&span_b)
  • Passing just the ID, keeping the span alive: span_a.follows_from(span_b.id())

@ThomWright ThomWright merged commit e6fc44d into main Apr 29, 2024
12 checks passed
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