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

"Tried to clone Id(1), but no span exists with that ID" when setting parent span #688

Closed
asayers opened this issue Apr 23, 2020 · 4 comments · Fixed by #1003
Closed

"Tried to clone Id(1), but no span exists with that ID" when setting parent span #688

asayers opened this issue Apr 23, 2020 · 4 comments · Fixed by #1003
Labels
kind/bug Something isn't working

Comments

@asayers
Copy link

asayers commented Apr 23, 2020

(Not a real issue, just leaving this here to help future searchers.)

The docs tell you to explicitly set a parent span like this:

let span1 = info_span!("my great span");
let span2 = info_span!(parent: &span1, "child of great span");

And this works. However, if you forget to borrow span1 and do this...

let span1 = info_span!("my great span");
let span2 = info_span!(parent: span1, "child of great span");

...it will compile fine, but panic at runtime. 😞 It's clear what's going on here - span1 is converted into its ID, but in the process it's dropped and the ID is deregistered from the subscriber. Still, my brain is used to getting a compile-time errors when I miss an & and it took me a while to spot the mistake - so I thought I'd leave this here in hopes of helping the people of the future.

@asayers asayers closed this as completed Apr 23, 2020
@hawkw
Copy link
Member

hawkw commented Apr 23, 2020

Hmm, thanks for reporting this, that's definitely not great. We should look into potential API changes to stop this from happening.

@davidbarsky davidbarsky reopened this Apr 23, 2020
@davidbarsky
Copy link
Member

I've re-opened this issue because I think it's an ergonomic papercut and it'd be useful to track this.

@hawkw hawkw added the kind/bug Something isn't working label Apr 27, 2020
@ctiller
Copy link

ctiller commented Jul 28, 2020

Just ran into this converting a bunch of code I maintain to use tracing.

@hawkw
Copy link
Member

hawkw commented Jul 28, 2020

Yeah, we need to fix this. Unfortunately, I think it's going to need to wait until the next API breaking change.

joshtriplett added a commit to joshtriplett/tracing that referenced this issue Jul 30, 2021
This may help give the user a hint to start debugging this.

See tokio-rs#688 for further details
on this issue.
hawkw pushed a commit that referenced this issue Aug 1, 2021
…wing parents (#1483)

This may help give the user a hint to start debugging this.

See #688 for further details
on this issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants