Skip to content

Commit

Permalink
cherry pick #25264 to release-5.1
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
YinWeiling authored and ti-srebot committed Jun 18, 2021
1 parent 38175b9 commit 61d61c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion telemetry/data_slow_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func init() {
currentSQBInfo["+Inf"] = 0

if mysql.TiDBReleaseVersion != "None" {
logutil.BgLogger().Info("Telemetry slow query stats initialized", zap.String("currentSQBInfo", currentSQBInfo.String()), zap.String("lastSQBInfo", lastSQBInfo.String()))
logutil.BgLogger().Debug("Telemetry slow query stats initialized", zap.String("currentSQBInfo", currentSQBInfo.String()), zap.String("lastSQBInfo", lastSQBInfo.String()))
}
}

Expand Down
10 changes: 4 additions & 6 deletions telemetry/data_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"sync"
"time"

"github.com/pingcap/errors"
"github.com/pingcap/tidb/domain/infosync"
"github.com/pingcap/tidb/store/tikv/logutil"
"github.com/prometheus/client_golang/api"
Expand Down Expand Up @@ -110,12 +109,8 @@ func readSQLMetric(timepoint time.Time, SQLResult *sqlUsageData) error {
promQL := "sum(tidb_executor_statement_total{}) by (instance,type)"
result, err := querySQLMetric(ctx, timepoint, promQL)
if err != nil {
if err1, ok := err.(*promv1.Error); ok {
return errors.Errorf("query metric error, msg: %v, detail: %v", err1.Msg, err1.Detail)
}
return errors.Errorf("query metric error: %v", err.Error())
logutil.BgLogger().Warn("querySQLMetric got error")
}

anylisSQLUsage(result, SQLResult)
return nil
}
Expand Down Expand Up @@ -155,6 +150,9 @@ func querySQLMetric(ctx context.Context, queryTime time.Time, promQL string) (re
}

func anylisSQLUsage(promResult pmodel.Value, SQLResult *sqlUsageData) {
if promResult == nil {
return
}
switch promResult.Type() {
case pmodel.ValVector:
matrix := promResult.(pmodel.Vector)
Expand Down

0 comments on commit 61d61c3

Please sign in to comment.