Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

telemetry: add simple report for playground #1353

Merged
merged 3 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,18 @@ var (
teleCommand string
)

// arguments
var (
binary string
binPath string
tag string
printVersion bool // not using cobra.Command.Version to make it possible to show component versions
)

func init() {
cobra.EnableCommandSorting = false
_ = os.Setenv(localdata.EnvNameTelemetryEventUUID, eventUUID)

var (
binary string
binPath string
tag string
printVersion bool // not using cobra.Command.Version to make it possible to show component versions
)

rootCmd = &cobra.Command{
Use: `tiup [flags] <command> [args...]
tiup [flags] <component> [args...]`,
Expand Down Expand Up @@ -226,6 +227,9 @@ func Execute() {
teleReport.Version.TiUPVersion = version.NewTiUPVersion().SemVer()
tiupReport.Command = teleCommand
tiupReport.CustomMirror = env.Profile().Config.Mirror != repository.DefaultMirror
if tag != "" {
tiupReport.Tag = telemetry.SaltedHash(tag)
}

f := func() {
defer func() {
Expand Down
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
8 changes: 6 additions & 2 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 All @@ -57,8 +62,7 @@ var cm *manager.Manager
func scrubClusterName(n string) string {
// prepend the telemetry secret to cluster name, so that two installations
// of tiup with the same cluster name produce different hashes
cls := telemetry.GetSecret() + ":" + n
return "cluster_" + telemetry.HashReport(cls)
return "cluster_" + telemetry.SaltedHash(n)
}

func getParentNames(cmd *cobra.Command) []string {
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