-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
util/tracing: fix an edge case for active span registration #70850
Conversation
11d726c
to
f07be42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @aayushshah15 and @andreimatei)
pkg/util/tracing/span_options.go, line 147 at r2 (raw file):
// obligation to manually propagate the trace data to the parent Span. func WithParentAndAutoCollection(sp *Span) SpanOption { if sp == nil {
Nit: This can be written as:
if sp == nil || sp.IsNoop() {
return (*parentAndAutoCollectionOption)(nil)
}
return (*parentAndAutoCollectionOption)(sp)
This was hidden in an internal helper, but it's such a common concern that it deserves better ergonomics, and it even deserves to be public. Release note: None
Before this patch, a span with a no-op parent (as opposed to a span with no parent), would not be present in the active spans registry. The code was confused: the span didn't qualify as a "local root" because it had a local parent, but of course it also wasn't really recorded by the local parent cause a no-op span can't record anything. As such, the span in question was missing from the registry. This patch makes a span with a no-op parent behave like a root span. Release note: None
f07be42
to
f299cf2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTR!
bors r+
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @aayushshah15 and @rimadeodhar)
pkg/util/tracing/span_options.go, line 147 at r2 (raw file):
Previously, rimadeodhar (Rima Deodhar) wrote…
Nit: This can be written as:
if sp == nil || sp.IsNoop() { return (*parentAndAutoCollectionOption)(nil) } return (*parentAndAutoCollectionOption)(sp)
done
Build succeeded: |
Before this patch, a span with a no-op parent (as opposed to a span
with no parent), would not be present in the active spans registry. The
code was confused: the span didn't qualify as a "local root" because it
had a local parent, but of course it also wasn't really recorded by the
local parent cause a no-op span can't record anything. As such, the span
in question was missing from the registry.
This patch makes a span with a no-op parent behave like a root span.
Release note: None