fix: Unparent connection span #868
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
Connectionstruct contains atracing::Spantracking itslifetime. This can be useful. The problem is that this span has as its
parent the span within which the connection is created, meaning that it
keeps that span alive (not closed) while it is alive. In practice that
means, for example, instrumented functions that create connections and
store those connections for reuse will not have their spans closed and
exported when they end.
This shows up in
tonic, where the first RPC call to any server will have its containing span alive for the remainder of the RPC client's lifetime.This commit sets the
Connection's span's parent toNoneand gives ita "follows-from" relation to the span in which it was created instead.
This shows the causal relationship between them, without tying the
creating span's lifetime to the connection's lifetime.