Skip to content

Commit

Permalink
telemetry: fix the bug about unnecessary error when run tidb only (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
YinWeiling authored Jun 18, 2021
1 parent 979f535 commit 1314b08
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/prometheus/client_golang/api"
promv1 "github.com/prometheus/client_golang/api/prometheus/v1"
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 1314b08

Please sign in to comment.