Skip to content

Commit

Permalink
telemetry: add telemetry for playground
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed May 8, 2021
1 parent 1cf5fc2 commit 160f7a4
Show file tree
Hide file tree
Showing 9 changed files with 359 additions and 257 deletions.
8 changes: 0 additions & 8 deletions components/cluster/command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ import (
"github.com/spf13/cobra"
)

var (
teleReport *telemetry.Report
clusterReport *telemetry.ClusterReport
teleNodeInfos []*telemetry.NodeInfo
teleTopology string
teleCommand []string
)

var (
errNSDeploy = errNS.NewSubNamespace("deploy")
errDeployNameDuplicate = errNSDeploy.NewType("name_dup", errutil.ErrTraitPreCheck)
Expand Down
5 changes: 5 additions & 0 deletions components/cluster/command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ var (
gOpt operator.Options
skipConfirm bool
reportEnabled bool // is telemetry report enabled
teleReport *telemetry.Report
clusterReport *telemetry.ClusterReport
teleNodeInfos []*telemetry.NodeInfo
teleTopology string
teleCommand []string
)

var tidbSpec *spec.SpecManager
Expand Down
70 changes: 35 additions & 35 deletions components/playground/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ type Command struct {
instance.Config
}

func buildCommands(tp CommandType, opt *bootOptions) (cmds []Command) {
func buildCommands(tp CommandType, opt *BootOptions) (cmds []Command) {
commands := []struct {
comp string
instance.Config
}{
{"pd", opt.pd},
{"tikv", opt.tikv},
{"pump", opt.pump},
{"tiflash", opt.tiflash},
{"tidb", opt.tidb},
{"ticdc", opt.ticdc},
{"drainer", opt.drainer},
{"pd", opt.PD},
{"tikv", opt.TiKV},
{"pump", opt.Pump},
{"tiflash", opt.TiFlash},
{"tidb", opt.TiDB},
{"ticdc", opt.TiCDC},
{"drainer", opt.Drainer},
}

for _, cmd := range commands {
Expand All @@ -74,7 +74,7 @@ func buildCommands(tp CommandType, opt *bootOptions) (cmds []Command) {
}

func newScaleOut() *cobra.Command {
var opt bootOptions
var opt BootOptions
cmd := &cobra.Command{
Use: "scale-out instances",
Example: "tiup playground scale-out --db 1",
Expand All @@ -93,31 +93,31 @@ func newScaleOut() *cobra.Command {
Hidden: false,
}

cmd.Flags().IntVarP(&opt.tidb.Num, "db", "", opt.tidb.Num, "TiDB instance number")
cmd.Flags().IntVarP(&opt.tikv.Num, "kv", "", opt.tikv.Num, "TiKV instance number")
cmd.Flags().IntVarP(&opt.pd.Num, "pd", "", opt.pd.Num, "PD instance number")
cmd.Flags().IntVarP(&opt.tiflash.Num, "tiflash", "", opt.tiflash.Num, "TiFlash instance number")
cmd.Flags().IntVarP(&opt.ticdc.Num, "ticdc", "", opt.ticdc.Num, "TiCDC instance number")
cmd.Flags().IntVarP(&opt.pump.Num, "pump", "", opt.pump.Num, "Pump instance number")
cmd.Flags().IntVarP(&opt.drainer.Num, "drainer", "", opt.pump.Num, "Drainer instance number")

cmd.Flags().StringVarP(&opt.tidb.Host, "db.host", "", opt.tidb.Host, "Playground TiDB host. If not provided, TiDB will still use `host` flag as its host")
cmd.Flags().StringVarP(&opt.pd.Host, "pd.host", "", opt.pd.Host, "Playground PD host. If not provided, PD will still use `host` flag as its host")

cmd.Flags().StringVarP(&opt.tidb.ConfigPath, "db.config", "", opt.tidb.ConfigPath, "TiDB instance configuration file")
cmd.Flags().StringVarP(&opt.tikv.ConfigPath, "kv.config", "", opt.tikv.ConfigPath, "TiKV instance configuration file")
cmd.Flags().StringVarP(&opt.pd.ConfigPath, "pd.config", "", opt.pd.ConfigPath, "PD instance configuration file")
cmd.Flags().StringVarP(&opt.tidb.ConfigPath, "tiflash.config", "", opt.tidb.ConfigPath, "TiFlash instance configuration file")
cmd.Flags().StringVarP(&opt.pump.ConfigPath, "pump.config", "", opt.pump.ConfigPath, "Pump instance configuration file")
cmd.Flags().StringVarP(&opt.drainer.ConfigPath, "drainer.config", "", opt.drainer.ConfigPath, "Drainer instance configuration file")

cmd.Flags().StringVarP(&opt.tidb.BinPath, "db.binpath", "", opt.tidb.BinPath, "TiDB instance binary path")
cmd.Flags().StringVarP(&opt.tikv.BinPath, "kv.binpath", "", opt.tikv.BinPath, "TiKV instance binary path")
cmd.Flags().StringVarP(&opt.pd.BinPath, "pd.binpath", "", opt.pd.BinPath, "PD instance binary path")
cmd.Flags().StringVarP(&opt.tiflash.BinPath, "tiflash.binpath", "", opt.tiflash.BinPath, "TiFlash instance binary path")
cmd.Flags().StringVarP(&opt.ticdc.BinPath, "ticdc.binpath", "", opt.ticdc.BinPath, "TiCDC instance binary path")
cmd.Flags().StringVarP(&opt.pump.BinPath, "pump.binpath", "", opt.pump.BinPath, "Pump instance binary path")
cmd.Flags().StringVarP(&opt.drainer.BinPath, "drainer.binpath", "", opt.drainer.BinPath, "Drainer instance binary path")
cmd.Flags().IntVarP(&opt.TiDB.Num, "db", "", opt.TiDB.Num, "TiDB instance number")
cmd.Flags().IntVarP(&opt.TiKV.Num, "kv", "", opt.TiKV.Num, "TiKV instance number")
cmd.Flags().IntVarP(&opt.PD.Num, "pd", "", opt.PD.Num, "PD instance number")
cmd.Flags().IntVarP(&opt.TiFlash.Num, "tiflash", "", opt.TiFlash.Num, "TiFlash instance number")
cmd.Flags().IntVarP(&opt.TiCDC.Num, "ticdc", "", opt.TiCDC.Num, "TiCDC instance number")
cmd.Flags().IntVarP(&opt.Pump.Num, "pump", "", opt.Pump.Num, "Pump instance number")
cmd.Flags().IntVarP(&opt.Drainer.Num, "drainer", "", opt.Pump.Num, "Drainer instance number")

cmd.Flags().StringVarP(&opt.TiDB.Host, "db.host", "", opt.TiDB.Host, "Playground TiDB host. If not provided, TiDB will still use `host` flag as its host")
cmd.Flags().StringVarP(&opt.PD.Host, "pd.host", "", opt.PD.Host, "Playground PD host. If not provided, PD will still use `host` flag as its host")

cmd.Flags().StringVarP(&opt.TiDB.ConfigPath, "db.config", "", opt.TiDB.ConfigPath, "TiDB instance configuration file")
cmd.Flags().StringVarP(&opt.TiKV.ConfigPath, "kv.config", "", opt.TiKV.ConfigPath, "TiKV instance configuration file")
cmd.Flags().StringVarP(&opt.PD.ConfigPath, "pd.config", "", opt.PD.ConfigPath, "PD instance configuration file")
cmd.Flags().StringVarP(&opt.TiDB.ConfigPath, "tiflash.config", "", opt.TiDB.ConfigPath, "TiFlash instance configuration file")
cmd.Flags().StringVarP(&opt.Pump.ConfigPath, "pump.config", "", opt.Pump.ConfigPath, "Pump instance configuration file")
cmd.Flags().StringVarP(&opt.Drainer.ConfigPath, "drainer.config", "", opt.Drainer.ConfigPath, "Drainer instance configuration file")

cmd.Flags().StringVarP(&opt.TiDB.BinPath, "db.binpath", "", opt.TiDB.BinPath, "TiDB instance binary path")
cmd.Flags().StringVarP(&opt.TiKV.BinPath, "kv.binpath", "", opt.TiKV.BinPath, "TiKV instance binary path")
cmd.Flags().StringVarP(&opt.PD.BinPath, "pd.binpath", "", opt.PD.BinPath, "PD instance binary path")
cmd.Flags().StringVarP(&opt.TiFlash.BinPath, "tiflash.binpath", "", opt.TiFlash.BinPath, "TiFlash instance binary path")
cmd.Flags().StringVarP(&opt.TiCDC.BinPath, "ticdc.binpath", "", opt.TiCDC.BinPath, "TiCDC instance binary path")
cmd.Flags().StringVarP(&opt.Pump.BinPath, "pump.binpath", "", opt.Pump.BinPath, "Pump instance binary path")
cmd.Flags().StringVarP(&opt.Drainer.BinPath, "drainer.binpath", "", opt.Drainer.BinPath, "Drainer instance binary path")

return cmd
}
Expand Down Expand Up @@ -173,7 +173,7 @@ func scaleIn(pids []int) error {
return sendCommandsAndPrintResult(cmds, addr)
}

func scaleOut(args []string, opt *bootOptions) (num int, err error) {
func scaleOut(args []string, opt *BootOptions) (num int, err error) {
port, err := targetTag()
if err != nil {
return 0, err
Expand Down
10 changes: 5 additions & 5 deletions components/playground/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (

// Config of the instance.
type Config struct {
ConfigPath string
BinPath string
Num int
Host string
UpTimeout int
ConfigPath string `yaml:"config_path"`
BinPath string `yaml:"bin_path"`
Num int `yaml:"num"`
Host string `yaml:"host"`
UpTimeout int `yaml:"up_timeout"`
}

type instance struct {
Expand Down
Loading

0 comments on commit 160f7a4

Please sign in to comment.