-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
56238: tracing: make Span.crdbSpan a pointer r=RaduBerinde,irfansharif a=tbg A `Span` essentially fans out over any subset of the below: - CRDB trace span - net/trace span - external opentracing-comatible tracer Span The latter two are already pointers, which means that there is a convenient check for their absence in tracing-internal code. This wasn't true for crdbSpan, which has bitten me in the past. Make things more idiomatic by using a pointer for this one, too. As currently written, our tracer will always populate the crdbSpan whenever net/trace or opentracing tracers are active. However, there is no good reason to do that, and even if there were, it should not reflect as a fundamental requirement in the code. One nice outcome of this change is that the noopSpan is now `&Span{tracer: t}`, and all fields except for the tracer are nil, meaning that any bug around noop spans will quickly manifest as an NPE. (One past bug involved erroneously assigning an operation name to the noopSpan). Other than a few clarification that resulted from the pointer change, this commit also improves `startSpanGeneric` to avoid populating a struct's internals after the initial assignment, a pattern which I have found easier to get wrong. Now, all ingredients are held in local variables, which are assigned to `crdbSpan` wholesale. Release note: None Co-authored-by: Tobias Grieger <[email protected]>
- Loading branch information
Showing
5 changed files
with
185 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.