-
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 telemetry for some partitioning UX improvements
Add telemetry for the following operations: * show partitions * show ranges * show locality * show create table (intending to capture usage of new partitioning info) Release justification: Low risk improvement to monitoring. Release note: None
- Loading branch information
Rohan Yadav
committed
Sep 17, 2019
1 parent
5cee194
commit d0a699d
Showing
8 changed files
with
97 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
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,58 @@ | ||
// 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" | ||
) | ||
|
||
// ShowTelemetryType is an enum used to represent the different show commands | ||
// that we are recording telemetry for. | ||
type ShowTelemetryType int | ||
|
||
const ( | ||
_ ShowTelemetryType = iota | ||
// Ranges represents the SHOW RANGES command. | ||
Ranges | ||
// Partitions represents the SHOW PARTITIONS command. | ||
Partitions | ||
// Locality represents the SHOW LOCALITY command. | ||
Locality | ||
// Create represents the SHOW CREATE command. | ||
Create | ||
) | ||
|
||
var showTelemetryNameMap = map[ShowTelemetryType]string{ | ||
Ranges: "ranges", | ||
Partitions: "partitions", | ||
Locality: "locality", | ||
Create: "create", | ||
} | ||
|
||
func (s ShowTelemetryType) String() string { | ||
return showTelemetryNameMap[s] | ||
} | ||
|
||
var showTelemetryCounters map[ShowTelemetryType]telemetry.Counter | ||
|
||
func init() { | ||
showTelemetryCounters = make(map[ShowTelemetryType]telemetry.Counter) | ||
for ty, s := range showTelemetryNameMap { | ||
showTelemetryCounters[ty] = telemetry.GetCounterOnce(fmt.Sprintf("sql.show.%s", s)) | ||
} | ||
} | ||
|
||
// IncrementShowCounter is used to increment the telemetry counter for a particular show command. | ||
func IncrementShowCounter(showType ShowTelemetryType) { | ||
telemetry.Inc(showTelemetryCounters[showType]) | ||
} |