Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: add telemetry for uses of alter primary key #44719

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/sql/alter_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ func (n *alterTableNode) startExec(params runParams) error {
"session variable experimental_enable_primary_key_changes is set to false, cannot perform primary key change")
}

// Increment telemetry about uses of primary key changes.
telemetry.Inc(sqltelemetry.AlterPrimaryKeyCounter)

// Ensure that there is not another primary key change attempted within this transaction.
currentMutationID := n.tableDesc.ClusterVersion.NextMutationID
for i := range n.tableDesc.Mutations {
Expand Down
5 changes: 5 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/alter_primary_key
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ SELECT * from t@primary
2 6 7 8
9 10 11 12

query T
select feature_name FROM crdb_internal.feature_usage WHERE feature_name = 'sql.schema.alter_primary_key' AND usage_count > 0
----
sql.schema.alter_primary_key

# Test primary key changes on storing indexes with different column families (the randomizer will do this for us).
statement ok
DROP TABLE t;
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql/sqltelemetry/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ var CreateTempTableCounter = telemetry.GetCounterOnce("sql.schema.create_temp_ta
// SecondaryIndexColumnFamiliesCounter is a counter that is incremented every time
// a secondary index that is separated into different column families is created.
var SecondaryIndexColumnFamiliesCounter = telemetry.GetCounterOnce("sql.schema.secondary_index_column_families")

// AlterPrimaryKeyCounter is a counter that is incremented every time the
// ALTER PRIMARY KEY command is used.
var AlterPrimaryKeyCounter = telemetry.GetCounterOnce("sql.schema.alter_primary_key")