From 9b9e15b791f407a1ecd42c382f4b1f9a737ed386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Mon, 6 Feb 2023 16:21:57 +0100 Subject: [PATCH] telemetry: Log error reason for failure to get SQL Metric (#40778) close pingcap/tidb#40777 --- telemetry/data_feature_usage.go | 3 ++- telemetry/data_slow_query.go | 2 +- telemetry/data_window.go | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/telemetry/data_feature_usage.go b/telemetry/data_feature_usage.go index 8661ce13ecccb..1fe696870c291 100644 --- a/telemetry/data_feature_usage.go +++ b/telemetry/data_feature_usage.go @@ -29,6 +29,7 @@ import ( "github.com/pingcap/tidb/util/memory" "github.com/pingcap/tidb/util/sqlexec" "github.com/tikv/client-go/v2/metrics" + "go.uber.org/zap" ) // emptyClusterIndexUsage is empty ClusterIndexUsage, deprecated. @@ -81,7 +82,7 @@ func getFeatureUsage(ctx context.Context, sctx sessionctx.Context) (*featureUsag var err error usage.NewClusterIndex, usage.ClusterIndex, err = getClusterIndexUsageInfo(ctx, sctx) if err != nil { - logutil.BgLogger().Info(err.Error()) + logutil.BgLogger().Info("Failed to get feature usage", zap.Error(err)) return nil, err } diff --git a/telemetry/data_slow_query.go b/telemetry/data_slow_query.go index 791b5f9b51bbe..b686db8d41105 100644 --- a/telemetry/data_slow_query.go +++ b/telemetry/data_slow_query.go @@ -64,7 +64,7 @@ var ( func getSlowQueryStats() (*slowQueryStats, error) { slowQueryBucket, err := getSlowQueryBucket() if err != nil { - logutil.BgLogger().Info(err.Error()) + logutil.BgLogger().Info("Failed to get Slow Query Stats", zap.Error(err)) return nil, err } diff --git a/telemetry/data_window.go b/telemetry/data_window.go index b0be7b841cbea..49a4037591b16 100644 --- a/telemetry/data_window.go +++ b/telemetry/data_window.go @@ -25,6 +25,7 @@ import ( promv1 "github.com/prometheus/client_golang/api/prometheus/v1" pmodel "github.com/prometheus/common/model" "go.uber.org/atomic" + "go.uber.org/zap" ) var ( @@ -253,7 +254,8 @@ func RotateSubWindow() { err := readSQLMetric(time.Now(), &thisSubWindow.SQLUsage) if err != nil { - logutil.BgLogger().Info("Error exists when getting the SQL Metric.") + logutil.BgLogger().Info("Error exists when getting the SQL Metric.", + zap.Error(err)) } thisSubWindow.SQLUsage.SQLTotal = getSQLSum(&thisSubWindow.SQLUsage.SQLType)