-
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.
schematelemetry: add job, schedule, controller and executor
This commit adds all the boilerplate for automatically scheduling SQL schema telemetry jobs, by default on a daily basis. This commit also adds a couple of builtins to create the job schedule and also to immediately create a schema telemetry logging job. Fixes #84284. Release note (sql change): this change ensures the existence of a new scheduled job for collecting SQL schema telemetry. By default it runs daily but this can be adjusted via the sql.schema.telemetry.recurrence cluster setting. The schedule can also be paused via PAUSE SCHEDULE followed by its ID, which can be retrieved by SELECT * FROM [SHOW SCHEDULES] WHERE label = 'sql-schema-telemetry'.
- Loading branch information
Marius Posta
committed
Jul 21, 2022
1 parent
0db7d8f
commit dcf7d5f
Showing
37 changed files
with
1,066 additions
and
10 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,26 +1,70 @@ | ||
load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "schematelemetry", | ||
srcs = ["schema_telemetry_event.go"], | ||
srcs = [ | ||
"scheduled_job_executor.go", | ||
"schema_telemetry_event.go", | ||
"schema_telemetry_job.go", | ||
], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/sql/catalog/schematelemetry", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//pkg/jobs", | ||
"//pkg/jobs/jobspb", | ||
"//pkg/kv", | ||
"//pkg/scheduledjobs", | ||
"//pkg/security/username", | ||
"//pkg/server/telemetry", | ||
"//pkg/settings", | ||
"//pkg/settings/cluster", | ||
"//pkg/sql", | ||
"//pkg/sql/catalog", | ||
"//pkg/sql/catalog/colinfo", | ||
"//pkg/sql/catalog/descpb", | ||
"//pkg/sql/catalog/descs", | ||
"//pkg/sql/catalog/schematelemetry/schematelemetrycontroller", | ||
"//pkg/sql/descmetadata", | ||
"//pkg/sql/schemachanger/scdecomp", | ||
"//pkg/sql/schemachanger/scpb", | ||
"//pkg/sql/schemachanger/screl", | ||
"//pkg/sql/sem/tree", | ||
"//pkg/sql/sqltelemetry", | ||
"//pkg/sql/sqlutil", | ||
"//pkg/util/hlc", | ||
"//pkg/util/log/eventpb", | ||
"//pkg/util/metric", | ||
"@com_github_cockroachdb_errors//:errors", | ||
"@com_github_gogo_protobuf//types", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "schematelemetry_test", | ||
srcs = [ | ||
"main_test.go", | ||
"schema_telemetry_test.go", | ||
], | ||
deps = [ | ||
"//pkg/base", | ||
"//pkg/jobs", | ||
"//pkg/jobs/jobstest", | ||
"//pkg/security/securityassets", | ||
"//pkg/security/securitytest", | ||
"//pkg/server", | ||
"//pkg/sql", | ||
"//pkg/sql/catalog/schematelemetry/schematelemetrycontroller", | ||
"//pkg/sql/sem/builtins/builtinconstants", | ||
"//pkg/sql/sem/tree", | ||
"//pkg/testutils/serverutils", | ||
"//pkg/testutils/sqlutils", | ||
"//pkg/testutils/testcluster", | ||
"//pkg/util/leaktest", | ||
"//pkg/util/log", | ||
"//pkg/util/timeutil", | ||
"@com_github_stretchr_testify//require", | ||
], | ||
) | ||
|
||
get_x_data(name = "get_x_data") |
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,31 @@ | ||
// Copyright 2022 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 schematelemetry_test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/security/securityassets" | ||
"github.com/cockroachdb/cockroach/pkg/security/securitytest" | ||
"github.com/cockroachdb/cockroach/pkg/server" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster" | ||
) | ||
|
||
//go:generate ../../../util/leaktest/add-leaktest.sh *_test.go | ||
|
||
func TestMain(m *testing.M) { | ||
securityassets.SetLoader(securitytest.EmbeddedAssets) | ||
serverutils.InitTestServerFactory(server.TestServerFactory) | ||
serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) | ||
os.Exit(m.Run()) | ||
} |
Oops, something went wrong.