-
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.
sqltelemetry,sql: Add telemetry for partitioning related improvements
This PR adds telemetry for the ALTER PARTITION FROM INDEX t@* command, as well as sets up some boilerplate code for adding more partitioning specific telemetry counters. Work for https://github.com/cockroachlabs/registration/issues/228. Release justification: Low risk monitoring improvement. Release note: None
- Loading branch information
Rohan Yadav
committed
Sep 18, 2019
1 parent
8e15411
commit 90a3f30
Showing
3 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2019 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 sqltelemetry | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/server/telemetry" | ||
) | ||
|
||
// PartitioningTelemetryType is an enum used to represent the different partitioning related operations | ||
// that we are recording telemetry for. | ||
type PartitioningTelemetryType int | ||
|
||
const ( | ||
_ PartitioningTelemetryType = iota | ||
// AlterAllPartitions represents an ALTER ALL PARTITIONS statement (ALTER PARTITION OF INDEX t@*) | ||
AlterAllPartitions | ||
) | ||
|
||
var partitioningTelemetryMap = map[PartitioningTelemetryType]string{ | ||
AlterAllPartitions: "alter-all-partitions", | ||
} | ||
|
||
func (p PartitioningTelemetryType) String() string { | ||
return partitioningTelemetryMap[p] | ||
} | ||
|
||
var partitioningTelemetryCounters map[PartitioningTelemetryType]telemetry.Counter | ||
|
||
func init() { | ||
partitioningTelemetryCounters = make(map[PartitioningTelemetryType]telemetry.Counter) | ||
for ty, s := range partitioningTelemetryMap { | ||
partitioningTelemetryCounters[ty] = telemetry.GetCounterOnce(fmt.Sprintf("sql.partitioning.%s", s)) | ||
} | ||
} | ||
|
||
// IncrementPartitioningCounter is used to increment the telemetry counter for a particular partitioning operation. | ||
func IncrementPartitioningCounter(partitioningType PartitioningTelemetryType) { | ||
telemetry.Inc(partitioningTelemetryCounters[partitioningType]) | ||
} |