Skip to content

Commit

Permalink
tracing: miscellaneous cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
irfansharif committed Jan 11, 2021
1 parent 8e4cd76 commit 623063e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ func runStart(cmd *cobra.Command, args []string, startSingleNode bool) (returnEr
// has completed.
// TODO(andrei): we don't close the span on the early returns below.
tracer := serverCfg.Settings.Tracer
sp := tracer.StartSpan("server start")
ctx = tracing.ContextWithSpan(ctx, sp)
startupSpan := tracer.StartSpan("server start")
ctx = tracing.ContextWithSpan(ctx, startupSpan)

// Set up the logging and profiling output.
//
Expand Down Expand Up @@ -543,7 +543,7 @@ If problems persist, please see %s.`
}()
// When the start up goroutine completes, so can the start up span
// defined above.
defer sp.Finish()
defer startupSpan.Finish()

// Any error beyond this point should be reported through the
// errChan defined above. However, in Go the code pattern "if err
Expand Down
1 change: 1 addition & 0 deletions pkg/server/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ func (n *Node) setupSpanForIncomingRPC(
if br == nil {
return
}
// TODO(irfansharif): How come this span is never Finish()-ed? #58721.
if grpcSpan != nil {
// If our local span descends from a parent on the other
// end of the RPC (i.e. the !isLocalRequest) case,
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/colflow/vectorized_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ func (s *vectorizedFlowCreator) setupOutput(
// Start a separate recording so that GetRecording will return
// the recordings for only the child spans containing stats.
ctx, span := tracing.ChildSpanRemote(ctx, "")
// TODO(irfansharif): How come this span is never Finish()-ed? #58721.
if atomic.AddInt32(&s.numOutboxesDrained, 1) == atomic.LoadInt32(&s.numOutboxes) {
// At the last outbox, we can accurately retrieve stats for the
// whole flow from parent monitors. These stats are added to a
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/conn_executor_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ func (ex *connExecutor) execStmtInOpenState(
if !alreadyRecording && stmtTraceThreshold > 0 {
ctx, stmtThresholdSpan = createRootOrChildSpan(ctx, "trace-stmt-threshold", ex.transitionCtx.tracer)
stmtThresholdSpan.SetVerbose(true)
// TODO(irfansharif): How come this span is never Finish()-ed? #58721.
}

if err := ex.dispatchToExecutionEngine(ctx, p, res); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/exec_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ type SessionTracing struct {
enabled bool

// kvTracingEnabled is set at times when KV tracing is active. When
// KV tracning is enabled, the SQL/KV interface logs individual K/V
// KV tracing is enabled, the SQL/KV interface logs individual K/V
// operators to the current context.
kvTracingEnabled bool

Expand Down
6 changes: 3 additions & 3 deletions pkg/sql/flowinfra/outbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ func (m *Outbox) mainLoop(ctx context.Context) error {
span.SetTag(execinfrapb.FlowIDTagKey, m.flowCtx.ID.String())
span.SetTag(execinfrapb.StreamIDTagKey, m.streamID)
}
// spanFinished specifies whether we called tracing.FinishSpan on the span.
// Some code paths (e.g. stats collection) need to prematurely call
// FinishSpan to get trace data.
// spanFinished specifies whether we've Finish()-ed the span. Some code
// paths (e.g. stats collection) need to prematurely call it to get trace
// data.
spanFinished := false
defer func() {
if !spanFinished {
Expand Down

0 comments on commit 623063e

Please sign in to comment.