Skip to content

Commit

Permalink
telemetry: remove the codes of Telemetry (pingcap#51202)
Browse files Browse the repository at this point in the history
  • Loading branch information
bb7133 authored Feb 22, 2024
1 parent 93e6a23 commit 3d1708f
Show file tree
Hide file tree
Showing 70 changed files with 10,242 additions and 15,139 deletions.
26 changes: 0 additions & 26 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3809,19 +3809,6 @@ def go_deps():
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/hydrogen18/memlistener/com_github_hydrogen18_memlistener-v0.0.0-20141126152155-54553eb933fb.zip",
],
)
go_repository(
name = "com_github_iancoleman_strcase",
build_file_proto_mode = "disable_global",
importpath = "github.com/iancoleman/strcase",
sha256 = "cb5027fec91d36426f0978a6c42ab52d8735fa3e1711be0127feda70a9a9fd05",
strip_prefix = "github.com/iancoleman/[email protected]",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/iancoleman/strcase/com_github_iancoleman_strcase-v0.2.0.zip",
"http://ats.apps.svc/gomod/github.com/iancoleman/strcase/com_github_iancoleman_strcase-v0.2.0.zip",
"https://cache.hawkingrei.com/gomod/github.com/iancoleman/strcase/com_github_iancoleman_strcase-v0.2.0.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/iancoleman/strcase/com_github_iancoleman_strcase-v0.2.0.zip",
],
)
go_repository(
name = "com_github_ianlancetaylor_demangle",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -4043,19 +4030,6 @@ def go_deps():
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/jedib0t/go-pretty/v6/com_github_jedib0t_go_pretty_v6-v6.2.2.zip",
],
)
go_repository(
name = "com_github_jeffail_gabs_v2",
build_file_proto_mode = "disable_global",
importpath = "github.com/Jeffail/gabs/v2",
sha256 = "3ddec4d5488c8505fa384ae20429c0735eda1ddbd0d15beeb0a5747ebded63c5",
strip_prefix = "github.com/Jeffail/gabs/[email protected]",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/Jeffail/gabs/v2/com_github_jeffail_gabs_v2-v2.5.1.zip",
"http://ats.apps.svc/gomod/github.com/Jeffail/gabs/v2/com_github_jeffail_gabs_v2-v2.5.1.zip",
"https://cache.hawkingrei.com/gomod/github.com/Jeffail/gabs/v2/com_github_jeffail_gabs_v2-v2.5.1.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/Jeffail/gabs/v2/com_github_jeffail_gabs_v2-v2.5.1.zip",
],
)
go_repository(
name = "com_github_jellydator_ttlcache_v3",
build_file_proto_mode = "disable_global",
Expand Down
10 changes: 0 additions & 10 deletions br/pkg/lightning/backend/kv/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,16 +373,6 @@ func (*Session) GetInfoSchema() infoschema.InfoSchemaMetaVersion {
return nil
}

// GetBuiltinFunctionUsage returns the BuiltinFunctionUsage of current Context, which is not thread safe.
// Use primitive map type to prevent circular import. Should convert it to telemetry.BuiltinFunctionUsage before using.
func (*Session) GetBuiltinFunctionUsage() map[string]uint32 {
return make(map[string]uint32)
}

// BuiltinFunctionUsageInc implements the sessionctx.Context interface.
func (*Session) BuiltinFunctionUsageInc(_ string) {
}

// GetStmtStats implements the sessionctx.Context interface.
func (*Session) GetStmtStats() *stmtstats.StatementStats {
return nil
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0
github.com/BurntSushi/toml v1.3.2
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/Jeffail/gabs/v2 v2.5.1
github.com/Masterminds/semver v1.5.0
github.com/Shopify/sarama v1.29.0
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1581
Expand Down Expand Up @@ -62,7 +61,6 @@ require (
github.com/gostaticanalysis/forcetypeassert v0.1.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/hashicorp/go-version v1.6.0
github.com/iancoleman/strcase v0.2.0
github.com/jedib0t/go-pretty/v6 v6.2.2
github.com/jellydator/ttlcache/v3 v3.0.1
github.com/jfcg/sorty/v2 v2.1.0
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM=
github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
github.com/Jeffail/gabs/v2 v2.5.1 h1:ANfZYjpMlfTTKebycu4X1AgkVWumFVDYQl7JwOr4mDk=
github.com/Jeffail/gabs/v2 v2.5.1/go.mod h1:xCn81vdHKxFUuWWAaD5jCTQDNPBMh5pPs9IJ+NcziBI=
github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY=
github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
Expand Down Expand Up @@ -486,8 +484,6 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/huandu/xstrings v1.3.1 h1:4jgBlKK6tLKFvO8u5pmYjG91cqytmDCDvGh7ECVFfFs=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/hydrogen18/memlistener v0.0.0-20141126152155-54553eb933fb/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE=
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
Expand Down
5 changes: 1 addition & 4 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ type Config struct {
Experimental Experimental `toml:"experimental" json:"experimental"`
// SkipRegisterToDashboard tells TiDB don't register itself to the dashboard.
SkipRegisterToDashboard bool `toml:"skip-register-to-dashboard" json:"skip-register-to-dashboard"`
// EnableTelemetry enables the usage data report to PingCAP.
// EnableTelemetry enables the usage data report to PingCAP. Deprecated: Telemetry has been removed.
EnableTelemetry bool `toml:"enable-telemetry" json:"enable-telemetry"`
// Labels indicates the labels set for the tidb server. The labels describe some specific properties for the tidb
// server like `zone`/`rack`/`host`. Currently, labels won't affect the tidb server except for some special
Expand Down Expand Up @@ -1473,9 +1473,6 @@ func init() {
}

func initByLDFlags(edition, checkBeforeDropLDFlag string) {
if edition != versioninfo.CommunityEdition {
defaultConf.EnableTelemetry = false
}
conf := defaultConf
StoreGlobalConfig(&conf)
if checkBeforeDropLDFlag == "1" {
Expand Down
6 changes: 3 additions & 3 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1205,8 +1205,8 @@ func TestModifyThroughLDFlags(t *testing.T) {
EnableTelemetry bool
CheckTableBeforeDrop bool
}{
{"Community", "None", true, false},
{"Community", "1", true, true},
{"Community", "None", false, false},
{"Community", "1", false, true},
{"Enterprise", "None", false, false},
{"Enterprise", "1", false, true},
}
Expand All @@ -1216,7 +1216,7 @@ func TestModifyThroughLDFlags(t *testing.T) {
originalGlobalConfig := GetGlobalConfig()

for _, test := range tests {
defaultConf.EnableTelemetry = true
defaultConf.EnableTelemetry = false
CheckTableBeforeDrop = false

initByLDFlags(test.Edition, test.CheckBeforeDropLDFlag)
Expand Down
3 changes: 0 additions & 3 deletions pkg/ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ const (
)

var (
telemetryAddIndexIngestUsage = metrics.TelemetryAddIndexIngestCnt
// SuppressErrorTooLongKeyKey is used by SchemaTracker to suppress err too long key error
SuppressErrorTooLongKeyKey stringutil.StringerStr = "suppressErrorTooLongKeyKey"
)
Expand Down Expand Up @@ -661,8 +660,6 @@ SwitchIndexState:
}
loadCloudStorageURI(w, job)
if reorgTp.NeedMergeProcess() {
// Increase telemetryAddIndexIngestUsage
telemetryAddIndexIngestUsage.Inc()
for _, indexInfo := range allIndexInfos {
indexInfo.BackfillState = model.BackfillStateRunning
}
Expand Down
1 change: 0 additions & 1 deletion pkg/distsql/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ go_library(
"//pkg/sessionctx/variable",
"//pkg/store/copr",
"//pkg/tablecodec",
"//pkg/telemetry",
"//pkg/types",
"//pkg/util/chunk",
"//pkg/util/codec",
Expand Down
39 changes: 0 additions & 39 deletions pkg/distsql/select_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/sessionctx/stmtctx"
"github.com/pingcap/tidb/pkg/store/copr"
"github.com/pingcap/tidb/pkg/telemetry"
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/chunk"
"github.com/pingcap/tidb/pkg/util/codec"
Expand All @@ -56,12 +55,6 @@ var (
errQueryInterrupted = dbterror.ClassExecutor.NewStd(errno.ErrQueryInterrupted)
)

var (
telemetryBatchedQueryTaskCnt = metrics.TelemetryBatchedQueryTaskCnt
telemetryStoreBatchedCnt = metrics.TelemetryStoreBatchedCnt
telemetryStoreBatchedFallbackCnt = metrics.TelemetryStoreBatchedFallbackCnt
)

var (
_ SelectResult = (*selectResult)(nil)
_ SelectResult = (*serialSelectResults)(nil)
Expand Down Expand Up @@ -321,35 +314,6 @@ type selectResult struct {
}

func (r *selectResult) fetchResp(ctx context.Context) error {
defer func() {
if r.stats != nil {
// Ignore internal sql.
if !r.ctx.GetSessionVars().InRestrictedSQL && r.stats.copRespTime.Size() > 0 {
ratio := r.stats.calcCacheHit()
if ratio >= 1 {
telemetry.CurrentCoprCacheHitRatioGTE100Count.Inc()
}
if ratio >= 0.8 {
telemetry.CurrentCoprCacheHitRatioGTE80Count.Inc()
}
if ratio >= 0.4 {
telemetry.CurrentCoprCacheHitRatioGTE40Count.Inc()
}
if ratio >= 0.2 {
telemetry.CurrentCoprCacheHitRatioGTE20Count.Inc()
}
if ratio >= 0.1 {
telemetry.CurrentCoprCacheHitRatioGTE10Count.Inc()
}
if ratio >= 0.01 {
telemetry.CurrentCoprCacheHitRatioGTE1Count.Inc()
}
if ratio >= 0 {
telemetry.CurrentCoprCacheHitRatioGTE0Count.Inc()
}
}
}
}()
for {
r.respChkIdx = 0
startTime := time.Now()
Expand Down Expand Up @@ -646,9 +610,6 @@ func (r *selectResult) Close() error {
batched, fallback := ci.GetStoreBatchInfo()
if batched != 0 || fallback != 0 {
r.stats.storeBatchedNum, r.stats.storeBatchedFallbackNum = batched, fallback
telemetryStoreBatchedCnt.Add(float64(r.stats.storeBatchedNum))
telemetryStoreBatchedFallbackCnt.Add(float64(r.stats.storeBatchedFallbackNum))
telemetryBatchedQueryTaskCnt.Add(float64(r.stats.copRespTime.Size()))
}
}
r.ctx.GetSessionVars().StmtCtx.RuntimeStatsColl.RegisterStats(r.rootPlanID, r.stats)
Expand Down
1 change: 0 additions & 1 deletion pkg/domain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ go_library(
"//pkg/statistics/handle/logutil",
"//pkg/statistics/handle/util",
"//pkg/store/helper",
"//pkg/telemetry",
"//pkg/ttl/cache",
"//pkg/ttl/sqlbuilder",
"//pkg/ttl/ttlworker",
Expand Down
59 changes: 0 additions & 59 deletions pkg/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ import (
"github.com/pingcap/tidb/pkg/statistics/handle"
statslogutil "github.com/pingcap/tidb/pkg/statistics/handle/logutil"
"github.com/pingcap/tidb/pkg/store/helper"
"github.com/pingcap/tidb/pkg/telemetry"
"github.com/pingcap/tidb/pkg/ttl/ttlworker"
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util"
Expand Down Expand Up @@ -1910,61 +1909,6 @@ func (do *Domain) globalBindHandleWorkerLoop(owner owner.Manager) {
}, "globalBindHandleWorkerLoop")
}

// TelemetryReportLoop create a goroutine that reports usage data in a loop, it should be called only once
// in BootstrapSession.
func (do *Domain) TelemetryReportLoop(ctx sessionctx.Context) {
ctx.GetSessionVars().InRestrictedSQL = true
err := telemetry.InitialRun(ctx, do.etcdClient)
if err != nil {
logutil.BgLogger().Warn("Initial telemetry run failed", zap.Error(err))
}

do.wg.Run(func() {
defer func() {
logutil.BgLogger().Info("TelemetryReportLoop exited.")
}()
defer util.Recover(metrics.LabelDomain, "TelemetryReportLoop", nil, false)

owner := do.newOwnerManager(telemetry.Prompt, telemetry.OwnerKey)
for {
select {
case <-do.exit:
owner.Cancel()
return
case <-time.After(telemetry.ReportInterval):
if !owner.IsOwner() {
continue
}
err := telemetry.ReportUsageData(ctx, do.etcdClient)
if err != nil {
// Only status update errors will be printed out
logutil.BgLogger().Warn("TelemetryReportLoop status update failed", zap.Error(err))
}
}
}
}, "TelemetryReportLoop")
}

// TelemetryRotateSubWindowLoop create a goroutine that rotates the telemetry window regularly.
func (do *Domain) TelemetryRotateSubWindowLoop(ctx sessionctx.Context) {
ctx.GetSessionVars().InRestrictedSQL = true
do.wg.Run(func() {
defer func() {
logutil.BgLogger().Info("TelemetryRotateSubWindowLoop exited.")
}()
defer util.Recover(metrics.LabelDomain, "TelemetryRotateSubWindowLoop", nil, false)

for {
select {
case <-do.exit:
return
case <-time.After(telemetry.SubWindowSize):
telemetry.RotateSubWindow()
}
}
}, "TelemetryRotateSubWindowLoop")
}

// SetupPlanReplayerHandle setup plan replayer handle
func (do *Domain) SetupPlanReplayerHandle(collectorSctx sessionctx.Context, workersSctxs []sessionctx.Context) {
ctx := kv.WithInternalSourceType(context.Background(), kv.InternalTxnStats)
Expand Down Expand Up @@ -2992,9 +2936,6 @@ func (do *Domain) StopAutoAnalyze() {

func init() {
initByLDFlagsForGlobalKill()
telemetry.GetDomainInfoSchema = func(ctx sessionctx.Context) infoschema.InfoSchema {
return GetDomain(ctx).InfoSchema()
}
}

var (
Expand Down
2 changes: 0 additions & 2 deletions pkg/executor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ go_library(
"adapter.go",
"admin.go",
"admin_plugins.go",
"admin_telemetry.go",
"analyze.go",
"analyze_col.go",
"analyze_col_v2.go",
Expand Down Expand Up @@ -179,7 +178,6 @@ go_library(
"//pkg/table/tables",
"//pkg/table/temptable",
"//pkg/tablecodec",
"//pkg/telemetry",
"//pkg/tidb-binlog/node",
"//pkg/types",
"//pkg/types/parser_driver",
Expand Down
Loading

0 comments on commit 3d1708f

Please sign in to comment.