Skip to content

Commit

Permalink
telemetry: add telemetry for the new autoid implementation (#38915)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored Nov 7, 2022
1 parent 21d6190 commit 30a76ce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions telemetry/data_feature_usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type featureUsage struct {
EnableCostModelVer2 bool `json:"enableCostModelVer2"`
DDLUsageCounter *m.DDLUsageCounter `json:"DDLUsageCounter"`
EnableGlobalMemoryControl bool `json:"enableGlobalMemoryControl"`
AutoIDNoCache bool `json:"autoIDNoCache"`
}

type placementPolicyUsage struct {
Expand Down Expand Up @@ -131,6 +132,9 @@ func collectFeatureUsageFromInfoschema(ctx sessionctx.Context, usage *featureUsa
if tbInfo.Meta().PlacementPolicyRef != nil {
usage.PlacementPolicyUsage.NumTableWithPolicies++
}
if tbInfo.Meta().AutoIdCache == 1 {
usage.AutoIDNoCache = true
}
partitions := tbInfo.Meta().GetPartitionInfo()
if partitions == nil {
continue
Expand Down
20 changes: 20 additions & 0 deletions telemetry/data_feature_usage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@ func TestCachedTable(t *testing.T) {
require.False(t, usage.CachedTable)
}

func TestAutoIDNoCache(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")

usage, err := telemetry.GetFeatureUsage(tk.Session())
require.NoError(t, err)
require.False(t, usage.CachedTable)
tk.MustExec("drop table if exists tele_autoid")
tk.MustExec("create table tele_autoid (id int) auto_id_cache 1")
usage, err = telemetry.GetFeatureUsage(tk.Session())
require.NoError(t, err)
require.True(t, usage.AutoIDNoCache)
tk.MustExec("alter table tele_autoid auto_id_cache=0")
usage, err = telemetry.GetFeatureUsage(tk.Session())
require.NoError(t, err)
require.False(t, usage.AutoIDNoCache)
}

func TestAccountLock(t *testing.T) {
store := testkit.CreateMockStore(t)

Expand Down

0 comments on commit 30a76ce

Please sign in to comment.