-
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.
57495: sql: add KV stats to TraceAnalyzer r=asubiotto a=cathymw The first commit adds total bytes and total rows read from KV to the TraceAnalyzer. Closes: #56605 The second commit adds cumulative time spent in KV to the TraceAnalyzer. Closes: #56604 Release note: None. Co-authored-by: Cathy <[email protected]>
- Loading branch information
Showing
4 changed files
with
163 additions
and
35 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
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 | ||
} | ||
} |