diff --git a/tools/pd-api-bench/cases/cases.go b/tools/pd-api-bench/cases/cases.go index f6f11c4e0f5..d289ecef06b 100644 --- a/tools/pd-api-bench/cases/cases.go +++ b/tools/pd-api-bench/cases/cases.go @@ -17,12 +17,13 @@ package cases import ( "context" "fmt" - "log" "math/rand" + "github.com/pingcap/log" pd "github.com/tikv/pd/client" pdHttp "github.com/tikv/pd/client/http" "go.etcd.io/etcd/clientv3" + "go.uber.org/zap" ) var ( @@ -51,7 +52,7 @@ func InitCluster(ctx context.Context, cli pd.Client, httpCli pdHttp.Client) erro for _, store := range stores { storesID = append(storesID, store.GetId()) } - log.Printf("This cluster has region %d, and store %d[%v]", totalRegion, totalStore, storesID) + log.Info("init cluster info", zap.Int("total-region", totalRegion), zap.Int("total-store", totalStore), zap.Any("store-ids", storesID)) return nil } @@ -182,7 +183,7 @@ func newMinResolvedTS() func() HTTPCase { func (c *minResolvedTS) Do(ctx context.Context, cli pdHttp.Client) error { minResolvedTS, storesMinResolvedTS, err := cli.GetMinResolvedTSByStoresIDs(ctx, storesID) if Debug { - log.Printf("Do %s: minResolvedTS: %d storesMinResolvedTS: %v err: %v", c.name, minResolvedTS, storesMinResolvedTS, err) + log.Info("do HTTP case", zap.String("case", c.name), zap.Uint64("min-resolved-ts", minResolvedTS), zap.Any("store-min-resolved-ts", storesMinResolvedTS), zap.Error(err)) } if err != nil { return err @@ -218,7 +219,7 @@ func (c *regionsStats) Do(ctx context.Context, cli pdHttp.Client) error { regionStats, err := cli.GetRegionStatusByKeyRange(ctx, pdHttp.NewKeyRange(generateKeyForSimulator(startID, 56), generateKeyForSimulator(endID, 56)), false) if Debug { - log.Printf("Do %s: regionStats: %v err: %v", c.name, regionStats, err) + log.Info("do HTTP case", zap.String("case", c.name), zap.Any("region-stats", regionStats), zap.Error(err)) } if err != nil { return err diff --git a/tools/pd-api-bench/main.go b/tools/pd-api-bench/main.go index b64bec40104..dff40555fd6 100644 --- a/tools/pd-api-bench/main.go +++ b/tools/pd-api-bench/main.go @@ -345,12 +345,6 @@ func runHTTPServer(cfg *config.Config, co *cases.Coordinator) { engine.Run(cfg.StatusAddr) } -func trimHTTPPrefix(str string) string { - str = strings.TrimPrefix(str, "http://") - str = strings.TrimPrefix(str, "https://") - return str -} - const ( keepaliveTime = 10 * time.Second keepaliveTimeout = 3 * time.Second @@ -369,7 +363,7 @@ func newEtcdClient(cfg *config.Config) *clientv3.Client { return nil } clientConfig := clientv3.Config{ - Endpoints: []string{trimHTTPPrefix(cfg.PDAddr)}, + Endpoints: []string{cfg.PDAddr}, DialTimeout: keepaliveTimeout, TLS: tlsCfg, LogConfig: &lgc, @@ -383,7 +377,7 @@ func newEtcdClient(cfg *config.Config) *clientv3.Client { // newPDClient returns a pd client. func newPDClient(ctx context.Context, cfg *config.Config) pd.Client { - addrs := []string{trimHTTPPrefix(cfg.PDAddr)} + addrs := []string{cfg.PDAddr} pdCli, err := pd.NewClientWithContext(ctx, addrs, pd.SecurityOption{ CAPath: cfg.CaPath, CertPath: cfg.CertPath,