-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: add cumulative KV time to TraceAnalyzer
This commit adds the total time spent waiting for KV requests to TraceAnalyzer. Release note: None.
- Loading branch information
Showing
4 changed files
with
109 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package execstats | ||
|
||
import ( | ||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb" | ||
) | ||
|
||
// Modifies TraceAnalyzer internal state to add stats for the processor/stream/flow specified | ||
// in stats.ComponentID and the given node ID. | ||
func (a *TraceAnalyzer) AddComponentStats( | ||
nodeID roachpb.NodeID, stats *execinfrapb.ComponentStats, | ||
) { | ||
switch stats.Component.Type { | ||
case execinfrapb.ComponentID_PROCESSOR: | ||
processorStat := &processorStats{ | ||
nodeID: nodeID, | ||
stats: stats, | ||
} | ||
if a.FlowMetadata.processorStats == nil { | ||
a.FlowMetadata.processorStats = make(map[execinfrapb.ProcessorID]*processorStats) | ||
} | ||
a.FlowMetadata.processorStats[execinfrapb.ProcessorID(stats.Component.ID)] = processorStat | ||
case execinfrapb.ComponentID_STREAM: | ||
streamStat := &streamStats{ | ||
originNodeID: nodeID, | ||
stats: stats, | ||
} | ||
if a.FlowMetadata.streamStats == nil { | ||
a.FlowMetadata.streamStats = make(map[execinfrapb.StreamID]*streamStats) | ||
} | ||
a.FlowMetadata.streamStats[execinfrapb.StreamID(stats.Component.ID)] = streamStat | ||
default: | ||
flowStat := &flowStats{ | ||
nodeID: nodeID, | ||
} | ||
flowStat.stats = append(flowStat.stats, stats) | ||
if a.FlowMetadata.flowStats == nil { | ||
a.FlowMetadata.flowStats = make(map[execinfrapb.FlowID]*flowStats) | ||
} | ||
a.FlowMetadata.flowStats[stats.Component.FlowID] = flowStat | ||
} | ||
} |