diff --git a/cmd/clean.go b/cmd/clean.go index be7d27e456..8510815269 100644 --- a/cmd/clean.go +++ b/cmd/clean.go @@ -32,6 +32,7 @@ func newCleanCmd() *cobra.Command { Use: "clean ", Short: "Clean the data of instantiated components", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() env := environment.GlobalEnv() if len(args) == 0 && !all { return cmd.Help() diff --git a/cmd/completion.go b/cmd/completion.go index 9607737e1c..87aa0256fa 100644 --- a/cmd/completion.go +++ b/cmd/completion.go @@ -52,6 +52,7 @@ func newCompletionCmd() *cobra.Command { SilenceUsage: true, SilenceErrors: true, RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() if len(args) == 1 { switch args[0] { case "bash": diff --git a/cmd/env.go b/cmd/env.go index 0ad71e3276..7f5756ec84 100644 --- a/cmd/env.go +++ b/cmd/env.go @@ -37,6 +37,7 @@ func newEnvCmd() *cobra.Command { Use: "env [name1...N]", Short: "Show the list of system environment variable that related to TiUP", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() if len(args) == 0 { showEnvList(true, envList...) return nil diff --git a/cmd/install.go b/cmd/install.go index 3dcd58ab64..3f05373ba5 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -33,6 +33,7 @@ of the same component: tiup install tidb:v3.0.5 tikv pd tiup install tidb:v3.0.5 tidb:v3.0.8 tikv:v3.0.9`, RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() env := environment.GlobalEnv() if len(args) == 0 { return cmd.Help() diff --git a/cmd/list.go b/cmd/list.go index c1aa5a55db..0c28f5c570 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -52,6 +52,7 @@ components or versions which have not been installed. SilenceUsage: true, SilenceErrors: true, RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() env := environment.GlobalEnv() switch len(args) { case 0: diff --git a/cmd/mirror.go b/cmd/mirror.go index 392c90f2f0..a2b04704b8 100644 --- a/cmd/mirror.go +++ b/cmd/mirror.go @@ -53,6 +53,7 @@ The repository can be used either online or offline. It also provides some useful utilities to help managing keys, users and versions of components or the repository itself.`, RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() if len(args) == 0 { return cmd.Help() } @@ -87,6 +88,7 @@ func newMirrorSignCmd() *cobra.Command { Short: "Add signatures to a manifest file", Long: fmt.Sprintf("Add signatures to a manifest file; if no key file is specified, ~/.tiup/keys/%s will be used", localdata.DefaultPrivateKeyName), RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() env := environment.GlobalEnv() if len(args) < 1 { return cmd.Help() @@ -148,6 +150,7 @@ func newMirrorShowCmd() *cobra.Command { Short: "Show mirror address", Long: `Show current mirror address`, RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() fmt.Println(environment.Mirror()) return nil }, @@ -169,6 +172,7 @@ func newMirrorSetCmd() *cobra.Command { directory. Relative paths will not be expanded, so absolute paths are recommended. The root manifest in $TIUP_HOME will be replaced with the one in given repository automatically.`, RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() if !reset && len(args) != 1 { return cmd.Help() } @@ -213,6 +217,7 @@ func newMirrorGrantCmd() *cobra.Command { Short: "grant a new owner", Long: "grant a new owner to current mirror", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() if len(args) < 1 { return cmd.Help() } @@ -265,6 +270,7 @@ func newMirrorModifyCmd() *cobra.Command { Short: "Modify published component", Long: "Modify component attributes (hidden, standalone, yanked)", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() if len(args) != 1 { return cmd.Help() } @@ -340,6 +346,7 @@ func newMirrorRotateCmd() *cobra.Command { Short: "Rotate root.json", Long: "Rotate root.json make it possible to modify root.json", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() root, err := editLatestRootManifest() if err != nil { return err @@ -473,6 +480,7 @@ func newMirrorPublishCmd() *cobra.Command { Short: "Publish a component", Long: "Publish a component to the repository", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() if len(args) != 4 { return cmd.Help() } @@ -612,6 +620,7 @@ func newMirrorGenkeyCmd() *cobra.Command { Short: "Generate a new key pair", Long: `Generate a new key pair that can be used to sign components.`, RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() env := environment.GlobalEnv() privPath := env.Profile().Path(localdata.KeyInfoParentDir, name+".json") keyDir := filepath.Dir(privPath) @@ -705,6 +714,7 @@ func newMirrorInitCmd() *cobra.Command { The specified path must be an empty directory. If the path does not exist, a new directory will be created.`, RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() if len(args) != 1 { return cmd.Help() } @@ -759,6 +769,7 @@ func newMirrorMergeCmd() *cobra.Command { tiup mirror merge tidb-community-v4.0.1 tidb-community-v4.0.2 # merge v4.0.1 and v4.0.2 into current mirror`, Short: "Merge two or more offline mirror", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() if len(args) < 1 { return cmd.Help() } @@ -837,6 +848,7 @@ func newMirrorCloneCmd() *cobra.Command { return initMirrorCloneExtraArgs(cmd) }, RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() cmd.DisableFlagParsing = false err := cmd.ParseFlags(args) if err != nil { diff --git a/cmd/root.go b/cmd/root.go index c2154fc1cc..894ce70779 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -14,27 +14,39 @@ package cmd import ( + "context" + "encoding/json" "errors" "fmt" "os" + "time" "github.com/fatih/color" + "github.com/google/uuid" perrs "github.com/pingcap/errors" "github.com/pingcap/tiup/pkg/environment" "github.com/pingcap/tiup/pkg/exec" + "github.com/pingcap/tiup/pkg/flags" "github.com/pingcap/tiup/pkg/localdata" "github.com/pingcap/tiup/pkg/logger/log" "github.com/pingcap/tiup/pkg/repository" "github.com/pingcap/tiup/pkg/repository/v1manifest" + "github.com/pingcap/tiup/pkg/telemetry" "github.com/pingcap/tiup/pkg/version" "github.com/spf13/cobra" ) -var rootCmd *cobra.Command -var repoOpts repository.Options +var ( + rootCmd *cobra.Command + repoOpts repository.Options + reportEnabled bool // is telemetry report enabled + eventUUID = uuid.New().String() + teleCommand string +) func init() { cobra.EnableCommandSorting = false + _ = os.Setenv(localdata.EnvNameTelemetryEventUUID, eventUUID) var ( binary string @@ -59,6 +71,7 @@ the latest stable version will be downloaded from the repository.`, return nil }, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() if printVersion && len(args) == 0 { return nil } @@ -116,6 +129,7 @@ the latest stable version will be downloaded from the repository.`, break } } + teleCommand = fmt.Sprintf("%s %s", cmd.CommandPath(), componentSpec) return exec.RunComponent(env, tag, componentSpec, binPath, transparentParams) } return cmd.Help() @@ -177,8 +191,74 @@ the latest stable version will be downloaded from the repository.`, // Execute parses the command line arguments and calls proper functions func Execute() { - if err := rootCmd.Execute(); err != nil { + start := time.Now() + code := 0 + + err := rootCmd.Execute() + if err != nil { fmt.Println(color.RedString("Error: %v", err)) - os.Exit(1) + code = 1 + } + + teleReport := new(telemetry.Report) + tiupReport := new(telemetry.TiUPReport) + teleReport.EventDetail = &telemetry.Report_Tiup{Tiup: tiupReport} + + env := environment.GlobalEnv() + if env == nil { + // if the env is not initialized, skip telemetry upload + // as many info are read from the env. + // TODO: split pure meta information from env object and + // us a dedicated package for that + reportEnabled = false + } else { + teleMeta, _, err := telemetry.GetMeta(env) + if err == nil { + reportEnabled = teleMeta.Status == telemetry.EnableStatus + teleReport.InstallationUUID = teleMeta.UUID + } // default to false on errors + } + + if reportEnabled { + teleReport.EventUUID = eventUUID + teleReport.EventUnixTimestamp = start.Unix() + teleReport.Version = telemetry.TiUPMeta() + teleReport.Version.TiUPVersion = version.NewTiUPVersion().SemVer() + tiupReport.Command = teleCommand + tiupReport.CustomMirror = env.Profile().Config.Mirror != repository.DefaultMirror + + f := func() { + defer func() { + if r := recover(); r != nil { + if flags.DebugMode { + log.Debugf("Recovered in telemetry report: %v", r) + } + } + }() + + tiupReport.ExitCode = int32(code) + tiupReport.TakeMilliseconds = uint64(time.Since(start).Milliseconds()) + tele := telemetry.NewTelemetry() + ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) + err := tele.Report(ctx, teleReport) + if flags.DebugMode { + if err != nil { + log.Infof("report failed: %v", err) + } + fmt.Printf("report: %s\n", teleReport.String()) + if data, err := json.Marshal(teleReport); err == nil { + log.Debugf("report: %s\n", string(data)) + } + } + cancel() + } + + f() + } + + color.Unset() + + if code != 0 { + os.Exit(code) } } diff --git a/cmd/status.go b/cmd/status.go index ba679a72ba..79ae3352a1 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -32,6 +32,7 @@ func newStatusCmd() *cobra.Command { Use: "status", Short: "List the status of instantiated components", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() env := environment.GlobalEnv() if len(args) > 0 { return cmd.Help() diff --git a/cmd/telemetry.go b/cmd/telemetry.go index 6c15d55806..441f6d8f4e 100644 --- a/cmd/telemetry.go +++ b/cmd/telemetry.go @@ -18,6 +18,7 @@ func newTelemetryCmd() *cobra.Command { Use: "reset", Short: "Reset the uuid used for telemetry", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() env := environment.GlobalEnv() teleMeta, fname, err := telemetry.GetMeta(env) if err != nil { @@ -39,6 +40,7 @@ func newTelemetryCmd() *cobra.Command { Use: "enable", Short: "Enable telemetry of tiup", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() env := environment.GlobalEnv() teleMeta, fname, err := telemetry.GetMeta(env) if err != nil { @@ -60,6 +62,7 @@ func newTelemetryCmd() *cobra.Command { Use: "disable", Short: "Disable telemetry of tiup", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() env := environment.GlobalEnv() teleMeta, fname, err := telemetry.GetMeta(env) if err != nil { @@ -81,6 +84,7 @@ func newTelemetryCmd() *cobra.Command { Use: "status", Short: "Display the current status of tiup telemetry", RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() env := environment.GlobalEnv() teleMeta, _, err := telemetry.GetMeta(env) if err != nil { diff --git a/cmd/uninstall.go b/cmd/uninstall.go index f1e5fd11f3..058727cd4c 100644 --- a/cmd/uninstall.go +++ b/cmd/uninstall.go @@ -48,6 +48,7 @@ which is used to uninstall tiup. # Uninstall all installed components tiup uninstall --all`, RunE: func(cmd *cobra.Command, args []string) error { + teleCommand = cmd.CommandPath() env := environment.GlobalEnv() if self { deletable := []string{"bin", "manifest", "manifests", "components", "storage/cluster/packages"} diff --git a/cmd/update.go b/cmd/update.go index f22c5801f2..fa9f9a87ef 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -40,6 +40,7 @@ latest version. All other flags will be ignored if the flag --self is given. $ tiup update playground:v0.0.3 --force # Overwrite an existing local installation $ tiup update --self # Update TiUP to the latest version`, RunE: func(cmd *cobra.Command, components []string) error { + teleCommand = cmd.CommandPath() if (len(components) == 0 && !all && !force && !self) || (len(components) > 0 && all) { return cmd.Help() } diff --git a/components/cluster/command/deploy.go b/components/cluster/command/deploy.go index f32c29b2cc..b82318b921 100644 --- a/components/cluster/command/deploy.go +++ b/components/cluster/command/deploy.go @@ -22,19 +22,18 @@ import ( "github.com/pingcap/tiup/pkg/cluster/executor" "github.com/pingcap/tiup/pkg/cluster/manager" operator "github.com/pingcap/tiup/pkg/cluster/operation" - "github.com/pingcap/tiup/pkg/cluster/report" "github.com/pingcap/tiup/pkg/cluster/spec" "github.com/pingcap/tiup/pkg/cluster/task" "github.com/pingcap/tiup/pkg/errutil" - telemetry2 "github.com/pingcap/tiup/pkg/telemetry" + "github.com/pingcap/tiup/pkg/telemetry" "github.com/pingcap/tiup/pkg/utils" "github.com/spf13/cobra" ) var ( - teleReport *telemetry2.Report - clusterReport *telemetry2.ClusterReport - teleNodeInfos []*telemetry2.NodeInfo + teleReport *telemetry.Report + clusterReport *telemetry.ClusterReport + teleNodeInfos []*telemetry.NodeInfo teleTopology string teleCommand []string ) @@ -104,7 +103,7 @@ func postDeployHook(builder *task.Builder, topo spec.Topology) { return nil }).BuildAsStep("Check status").SetHidden(true) - if report.Enabled() { + if telemetry.Enabled() { builder.ParallelStep("+ Check status", false, nodeInfoTask) } diff --git a/components/cluster/command/root.go b/components/cluster/command/root.go index 9f28220e5e..56dcef7e0e 100644 --- a/components/cluster/command/root.go +++ b/components/cluster/command/root.go @@ -26,14 +26,13 @@ import ( "github.com/joomcode/errorx" "github.com/pingcap/tiup/pkg/cliutil" "github.com/pingcap/tiup/pkg/cluster/executor" - "github.com/pingcap/tiup/pkg/cluster/flags" "github.com/pingcap/tiup/pkg/cluster/manager" operator "github.com/pingcap/tiup/pkg/cluster/operation" - "github.com/pingcap/tiup/pkg/cluster/report" "github.com/pingcap/tiup/pkg/cluster/spec" "github.com/pingcap/tiup/pkg/colorutil" tiupmeta "github.com/pingcap/tiup/pkg/environment" "github.com/pingcap/tiup/pkg/errutil" + "github.com/pingcap/tiup/pkg/flags" "github.com/pingcap/tiup/pkg/localdata" "github.com/pingcap/tiup/pkg/logger" "github.com/pingcap/tiup/pkg/logger/log" @@ -58,7 +57,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 := report.TelemetrySecret() + ":" + n + cls := telemetry.GetSecret() + ":" + n return "cluster_" + telemetry.HashReport(cls) } @@ -244,12 +243,16 @@ func Execute() { teleReport = new(telemetry.Report) clusterReport = new(telemetry.ClusterReport) teleReport.EventDetail = &telemetry.Report_Cluster{Cluster: clusterReport} - reportEnabled = report.Enabled() + reportEnabled = telemetry.Enabled() if reportEnabled { - teleReport.InstallationUUID = report.TelemetryUUID() - teleReport.EventUUID = uuid.New().String() + eventUUID := os.Getenv(localdata.EnvNameTelemetryEventUUID) + if eventUUID == "" { + eventUUID = uuid.New().String() + } + teleReport.InstallationUUID = telemetry.GetUUID() + teleReport.EventUUID = eventUUID teleReport.EventUnixTimestamp = time.Now().Unix() - teleReport.Tiup = report.TiUPMeta() + teleReport.Version = telemetry.TiUPMeta() } start := time.Now() @@ -289,7 +292,7 @@ func Execute() { "config": {}, "server_configs": {}, }, // fields to omit - report.TelemetrySecret(), + telemetry.GetSecret(), ); err == nil { clusterReport.Topology = (string(data)) } diff --git a/components/cluster/command/telemetry.go b/components/cluster/command/telemetry.go index d173d4d5f7..2eb3d8534d 100644 --- a/components/cluster/command/telemetry.go +++ b/components/cluster/command/telemetry.go @@ -17,9 +17,7 @@ import ( "context" "fmt" - telemetry2 "github.com/pingcap/tiup/pkg/telemetry" - - "github.com/pingcap/tiup/pkg/cluster/report" + "github.com/pingcap/tiup/pkg/telemetry" "github.com/spf13/cobra" ) @@ -48,13 +46,13 @@ func newTelemetryCmd() *cobra.Command { // nodeInfo dispaly telemetry.NodeInfo in stdout. func nodeInfo(ctx context.Context) error { - info := new(telemetry2.NodeInfo) - err := telemetry2.FillNodeInfo(ctx, info) + info := new(telemetry.NodeInfo) + err := telemetry.FillNodeInfo(ctx, info) if err != nil { return err } - text, err := report.NodeInfoToText(info) + text, err := telemetry.NodeInfoToText(info) if err != nil { return err } diff --git a/pkg/cluster/operation/telemetry.go b/pkg/cluster/operation/telemetry.go index 8a5861bd7d..10f1dbc5ca 100644 --- a/pkg/cluster/operation/telemetry.go +++ b/pkg/cluster/operation/telemetry.go @@ -23,7 +23,6 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/tiup/pkg/checkpoint" "github.com/pingcap/tiup/pkg/cluster/ctxt" - "github.com/pingcap/tiup/pkg/cluster/report" "github.com/pingcap/tiup/pkg/cluster/spec" "github.com/pingcap/tiup/pkg/telemetry" "github.com/pingcap/tiup/pkg/version" @@ -103,7 +102,7 @@ func GetNodeInfo( cmd = fmt.Sprintf("%s/cluster _telemetry node_info", dstDir) stdout, _, err := exec.Execute(nctx, cmd, false) if err == nil { - nodeInfo, err := report.NodeInfoFromText(string(stdout)) + nodeInfo, err := telemetry.NodeInfoFromText(string(stdout)) if err == nil { nodeInfo.NodeId = telemetry.HashReport(host) nodesMu.Lock() diff --git a/pkg/cluster/flags/debug.go b/pkg/flags/debug.go similarity index 100% rename from pkg/cluster/flags/debug.go rename to pkg/flags/debug.go diff --git a/pkg/localdata/constant.go b/pkg/localdata/constant.go index 7167d71c8e..eb843658d9 100644 --- a/pkg/localdata/constant.go +++ b/pkg/localdata/constant.go @@ -72,6 +72,9 @@ const ( // EnvNameTelemetryUUID represents the environment name of tiup telemetry uuid EnvNameTelemetryUUID = "TIUP_TELEMETRY_UUID" + // EnvNameTelemetryEventUUID represents the environment name of tiup telemetry event uuid + EnvNameTelemetryEventUUID = "TIUP_TELEMETRY_EVENT_UUID" + // EnvNameTelemetrySecret represents the environment name of tiup telemetry secret EnvNameTelemetrySecret = "TIUP_TELEMETRY_SECRET" diff --git a/pkg/cluster/report/report.go b/pkg/telemetry/report.go similarity index 74% rename from pkg/cluster/report/report.go rename to pkg/telemetry/report.go index 6cf852ddb1..440ceae827 100644 --- a/pkg/cluster/report/report.go +++ b/pkg/telemetry/report.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package report +package telemetry import ( "bytes" @@ -20,30 +20,29 @@ import ( "github.com/gogo/protobuf/proto" "github.com/pingcap/tiup/pkg/localdata" - tiuptele "github.com/pingcap/tiup/pkg/telemetry" "github.com/pingcap/tiup/pkg/version" ) // Enabled return true if we enable telemetry. func Enabled() bool { s := os.Getenv(localdata.EnvNameTelemetryStatus) - status := tiuptele.Status(s) - return status == tiuptele.EnableStatus + status := Status(s) + return status == EnableStatus } -// TelemetryUUID return telemetry uuid. -func TelemetryUUID() string { +// GetUUID return telemetry uuid. +func GetUUID() string { return os.Getenv(localdata.EnvNameTelemetryUUID) } -// TelemetrySecret return telemetry uuid. -func TelemetrySecret() string { +// GetSecret return telemetry encrypt secret. +func GetSecret() string { return os.Getenv(localdata.EnvNameTelemetrySecret) } // TiUPMeta returns metadata of TiUP Cluster itself -func TiUPMeta() *tiuptele.TiUPInfo { - return &tiuptele.TiUPInfo{ +func TiUPMeta() *TiUPInfo { + return &TiUPInfo{ TiUPVersion: os.Getenv(localdata.EnvNameTiUPVersion), ComponentVersion: version.NewTiUPVersion().SemVer(), GitCommit: version.NewTiUPBuildInfo().GitHash, @@ -53,8 +52,8 @@ func TiUPMeta() *tiuptele.TiUPInfo { } // NodeInfoFromText get telemetry.NodeInfo from the text. -func NodeInfoFromText(text string) (info *tiuptele.NodeInfo, err error) { - info = new(tiuptele.NodeInfo) +func NodeInfoFromText(text string) (info *NodeInfo, err error) { + info = new(NodeInfo) err = proto.UnmarshalText(text, info) if err != nil { return nil, err @@ -64,7 +63,7 @@ func NodeInfoFromText(text string) (info *tiuptele.NodeInfo, err error) { } // NodeInfoToText get telemetry.NodeInfo in text. -func NodeInfoToText(info *tiuptele.NodeInfo) (text string, err error) { +func NodeInfoToText(info *NodeInfo) (text string, err error) { buf := new(bytes.Buffer) err = proto.MarshalText(buf, info) if err != nil { diff --git a/pkg/telemetry/report.pb.go b/pkg/telemetry/report.pb.go index 50932af350..e8386d4562 100644 --- a/pkg/telemetry/report.pb.go +++ b/pkg/telemetry/report.pb.go @@ -30,9 +30,10 @@ type Report struct { EventUUID string `protobuf:"bytes,2,opt,name=eventUUID,proto3" json:"eventUUID,omitempty"` EventUnixTimestamp int64 `protobuf:"varint,3,opt,name=event_unix_timestamp,json=eventUnixTimestamp,proto3" json:"event_unix_timestamp,omitempty"` // Types that are valid to be assigned to EventDetail: + // *Report_Tiup // *Report_Cluster EventDetail isReport_EventDetail `protobuf_oneof:"event_detail"` - Tiup *TiUPInfo `protobuf:"bytes,5,opt,name=tiup,proto3" json:"tiup,omitempty"` + Version *TiUPInfo `protobuf:"bytes,6,opt,name=version,proto3" json:"version,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -77,10 +78,14 @@ type isReport_EventDetail interface { Size() int } +type Report_Tiup struct { + Tiup *TiUPReport `protobuf:"bytes,4,opt,name=tiup,proto3,oneof" json:"tiup,omitempty"` +} type Report_Cluster struct { - Cluster *ClusterReport `protobuf:"bytes,4,opt,name=cluster,proto3,oneof" json:"cluster,omitempty"` + Cluster *ClusterReport `protobuf:"bytes,5,opt,name=cluster,proto3,oneof" json:"cluster,omitempty"` } +func (*Report_Tiup) isReport_EventDetail() {} func (*Report_Cluster) isReport_EventDetail() {} func (m *Report) GetEventDetail() isReport_EventDetail { @@ -111,6 +116,13 @@ func (m *Report) GetEventUnixTimestamp() int64 { return 0 } +func (m *Report) GetTiup() *TiUPReport { + if x, ok := m.GetEventDetail().(*Report_Tiup); ok { + return x.Tiup + } + return nil +} + func (m *Report) GetCluster() *ClusterReport { if x, ok := m.GetEventDetail().(*Report_Cluster); ok { return x.Cluster @@ -118,9 +130,9 @@ func (m *Report) GetCluster() *ClusterReport { return nil } -func (m *Report) GetTiup() *TiUPInfo { +func (m *Report) GetVersion() *TiUPInfo { if m != nil { - return m.Tiup + return m.Version } return nil } @@ -128,10 +140,82 @@ func (m *Report) GetTiup() *TiUPInfo { // XXX_OneofWrappers is for the internal use of the proto package. func (*Report) XXX_OneofWrappers() []interface{} { return []interface{}{ + (*Report_Tiup)(nil), (*Report_Cluster)(nil), } } +type TiUPReport struct { + Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` + TakeMilliseconds uint64 `protobuf:"varint,2,opt,name=take_milliseconds,json=takeMilliseconds,proto3" json:"take_milliseconds,omitempty"` + ExitCode int32 `protobuf:"varint,3,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` + CustomMirror bool `protobuf:"varint,4,opt,name=custom_mirror,json=customMirror,proto3" json:"custom_mirror,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TiUPReport) Reset() { *m = TiUPReport{} } +func (m *TiUPReport) String() string { return proto.CompactTextString(m) } +func (*TiUPReport) ProtoMessage() {} +func (*TiUPReport) Descriptor() ([]byte, []int) { + return fileDescriptor_3eedb623aa6ca98c, []int{1} +} +func (m *TiUPReport) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TiUPReport) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TiUPReport.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TiUPReport) XXX_Merge(src proto.Message) { + xxx_messageInfo_TiUPReport.Merge(m, src) +} +func (m *TiUPReport) XXX_Size() int { + return m.Size() +} +func (m *TiUPReport) XXX_DiscardUnknown() { + xxx_messageInfo_TiUPReport.DiscardUnknown(m) +} + +var xxx_messageInfo_TiUPReport proto.InternalMessageInfo + +func (m *TiUPReport) GetCommand() string { + if m != nil { + return m.Command + } + return "" +} + +func (m *TiUPReport) GetTakeMilliseconds() uint64 { + if m != nil { + return m.TakeMilliseconds + } + return 0 +} + +func (m *TiUPReport) GetExitCode() int32 { + if m != nil { + return m.ExitCode + } + return 0 +} + +func (m *TiUPReport) GetCustomMirror() bool { + if m != nil { + return m.CustomMirror + } + return false +} + type ClusterReport struct { ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` Command string `protobuf:"bytes,2,opt,name=command,proto3" json:"command,omitempty"` @@ -149,7 +233,7 @@ func (m *ClusterReport) Reset() { *m = ClusterReport{} } func (m *ClusterReport) String() string { return proto.CompactTextString(m) } func (*ClusterReport) ProtoMessage() {} func (*ClusterReport) Descriptor() ([]byte, []int) { - return fileDescriptor_3eedb623aa6ca98c, []int{1} + return fileDescriptor_3eedb623aa6ca98c, []int{2} } func (m *ClusterReport) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -235,7 +319,7 @@ func (m *TiUPInfo) Reset() { *m = TiUPInfo{} } func (m *TiUPInfo) String() string { return proto.CompactTextString(m) } func (*TiUPInfo) ProtoMessage() {} func (*TiUPInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_3eedb623aa6ca98c, []int{2} + return fileDescriptor_3eedb623aa6ca98c, []int{3} } func (m *TiUPInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -312,7 +396,7 @@ func (m *NodeInfo) Reset() { *m = NodeInfo{} } func (m *NodeInfo) String() string { return proto.CompactTextString(m) } func (*NodeInfo) ProtoMessage() {} func (*NodeInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_3eedb623aa6ca98c, []int{3} + return fileDescriptor_3eedb623aa6ca98c, []int{4} } func (m *NodeInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -378,7 +462,7 @@ func (m *CPUInfo) Reset() { *m = CPUInfo{} } func (m *CPUInfo) String() string { return proto.CompactTextString(m) } func (*CPUInfo) ProtoMessage() {} func (*CPUInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_3eedb623aa6ca98c, []int{4} + return fileDescriptor_3eedb623aa6ca98c, []int{5} } func (m *CPUInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -463,7 +547,7 @@ func (m *HardwareInfo) Reset() { *m = HardwareInfo{} } func (m *HardwareInfo) String() string { return proto.CompactTextString(m) } func (*HardwareInfo) ProtoMessage() {} func (*HardwareInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_3eedb623aa6ca98c, []int{5} + return fileDescriptor_3eedb623aa6ca98c, []int{6} } func (m *HardwareInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -533,7 +617,7 @@ func (m *OSInfo) Reset() { *m = OSInfo{} } func (m *OSInfo) String() string { return proto.CompactTextString(m) } func (*OSInfo) ProtoMessage() {} func (*OSInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_3eedb623aa6ca98c, []int{6} + return fileDescriptor_3eedb623aa6ca98c, []int{7} } func (m *OSInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -595,7 +679,7 @@ func (m *MemInfo) Reset() { *m = MemInfo{} } func (m *MemInfo) String() string { return proto.CompactTextString(m) } func (*MemInfo) ProtoMessage() {} func (*MemInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_3eedb623aa6ca98c, []int{7} + return fileDescriptor_3eedb623aa6ca98c, []int{8} } func (m *MemInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -640,6 +724,7 @@ func (m *MemInfo) GetAvailable() uint64 { func init() { proto.RegisterType((*Report)(nil), "telemetry.Report") + proto.RegisterType((*TiUPReport)(nil), "telemetry.TiUPReport") proto.RegisterType((*ClusterReport)(nil), "telemetry.ClusterReport") proto.RegisterType((*TiUPInfo)(nil), "telemetry.TiUPInfo") proto.RegisterType((*NodeInfo)(nil), "telemetry.NodeInfo") @@ -652,51 +737,55 @@ func init() { func init() { proto.RegisterFile("report.proto", fileDescriptor_3eedb623aa6ca98c) } var fileDescriptor_3eedb623aa6ca98c = []byte{ - // 704 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x94, 0xcf, 0x4e, 0xdb, 0x4a, - 0x14, 0xc6, 0xb1, 0x93, 0x38, 0xf1, 0x81, 0x8b, 0xc2, 0x5c, 0x74, 0xb1, 0xb8, 0x57, 0xb9, 0x91, - 0x17, 0x85, 0x52, 0x89, 0xfe, 0x5f, 0x74, 0xd1, 0x0d, 0x41, 0x2a, 0x59, 0xd0, 0xa2, 0x29, 0x61, - 0x1b, 0x0d, 0xf6, 0x24, 0x8c, 0x98, 0xf1, 0x58, 0xf6, 0x38, 0x05, 0x5e, 0xa0, 0x4f, 0x50, 0xa9, - 0xea, 0x33, 0xf4, 0x41, 0x50, 0x57, 0x7d, 0x82, 0xaa, 0xa2, 0x8f, 0xd0, 0x17, 0xa8, 0x66, 0xc6, - 0x4e, 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xf5, - 0x8f, 0xff, 0x97, 0xf0, 0xdc, 0x8e, 0xb6, 0x4c, 0x88, 0xb6, 0x39, 0xb4, 0x56, 0x3b, 0xf4, 0xee, - 0x7d, 0xcd, 0xee, 0xca, 0x3c, 0xfc, 0xe4, 0x40, 0x7b, 0x70, 0x34, 0x32, 0x41, 0xfe, 0x01, 0x2f, - 0x29, 0x44, 0x94, 0x16, 0x26, 0x47, 0x0b, 0x97, 0x4a, 0x4f, 0x3d, 0x97, 0xd1, 0x39, 0x55, 0xb9, - 0x69, 0x49, 0x0b, 0x57, 0x12, 0xad, 0x43, 0x2b, 0x92, 0x19, 0xb5, 0x93, 0x6e, 0x61, 0x2b, 0x74, - 0x55, 0xc8, 0x98, 0xf2, 0xb2, 0x09, 0x56, 0xa0, 0x2e, 0x34, 0xc4, 0xd9, 0x95, 0x69, 0x83, 0x8b, - 0xf5, 0x52, 0x4f, 0x7a, 0x42, 0x89, 0x2a, 0xb2, 0x72, 0xa0, 0x3e, 0x9e, 0xeb, 0xf0, 0xab, 0x03, - 0x2b, 0x75, 0x42, 0xf4, 0x00, 0x56, 0x67, 0x2c, 0x53, 0x05, 0xe1, 0xec, 0xca, 0x7c, 0x71, 0x65, - 0xb3, 0xee, 0x54, 0xd1, 0x0e, 0x34, 0x34, 0x81, 0x6b, 0xd0, 0x51, 0xfd, 0x7b, 0xb1, 0x94, 0x25, - 0xbb, 0x36, 0x69, 0xaf, 0xa0, 0xc2, 0x84, 0xbf, 0xed, 0x3d, 0xa4, 0xa2, 0xee, 0x15, 0x54, 0xe8, - 0xa1, 0x73, 0x49, 0x62, 0x32, 0x9b, 0x3e, 0x7d, 0x69, 0xc0, 0x5c, 0xbc, 0x28, 0x84, 0x27, 0xe0, - 0xd9, 0xd6, 0xea, 0x26, 0x4e, 0x88, 0x60, 0xfc, 0xb2, 0x1a, 0xa6, 0x55, 0x1a, 0x36, 0xe5, 0x44, - 0x4d, 0x64, 0x26, 0xca, 0x87, 0x35, 0xd7, 0xba, 0xc1, 0xb3, 0xf2, 0xcd, 0xd9, 0xe7, 0x54, 0xc9, - 0xf0, 0x35, 0xb4, 0xcb, 0x2c, 0xba, 0xab, 0x4a, 0x2a, 0xc2, 0xcd, 0xbd, 0x4d, 0x6c, 0x85, 0x8e, - 0x45, 0x66, 0x84, 0x71, 0x72, 0xca, 0xa9, 0xb9, 0xb7, 0x89, 0x17, 0x85, 0xbd, 0xee, 0xf5, 0x4d, - 0xcf, 0xf9, 0x7e, 0xd3, 0x73, 0x7e, 0xde, 0xf4, 0x9c, 0xcf, 0xbf, 0x7a, 0x4b, 0xa7, 0x9e, 0xf9, - 0xc1, 0x3d, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0xd0, 0x2b, 0xff, 0x4c, 0x11, 0x05, 0x00, 0x00, + // 754 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x4e, 0x2b, 0x37, + 0x18, 0x65, 0x26, 0xbf, 0xf3, 0x11, 0x50, 0x70, 0x69, 0x19, 0xd1, 0x2a, 0x8d, 0xa6, 0x52, 0x4b, + 0x41, 0xa5, 0xff, 0x8b, 0x2e, 0xba, 0x21, 0x48, 0x25, 0x0b, 0x5a, 0xe4, 0x12, 0xb6, 0x91, 0x99, + 0x71, 0x82, 0x85, 0x3d, 0x1e, 0x79, 0x3c, 0x29, 0xf0, 0x02, 0x7d, 0x82, 0x4a, 0x55, 0x1f, 0xa0, + 0xab, 0x3e, 0x08, 0xea, 0xaa, 0x4f, 0x50, 0x5d, 0x71, 0x5f, 0xe4, 0xca, 0xf6, 0x4c, 0x32, 0x84, + 0x0d, 0xbb, 0x39, 0xc7, 0xc7, 0xe1, 0x9c, 0xf3, 0x7d, 0x18, 0x7a, 0x8a, 0x66, 0x52, 0xe9, 0xe3, + 0x4c, 0x49, 0x2d, 0x51, 0xa0, 0x29, 0xa7, 0x82, 0x6a, 0x75, 0x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3, 0x15, + 0x11, 0x5d, 0x41, 0xdb, 0x55, 0x6b, 0x4a, 0x9c, 0x11, 0xc1, 0xf8, 0x7d, 0x35, 0x4c, 0x87, 0x4c, + 0xd8, 0x8c, 0x13, 0x3d, 0x93, 0x4a, 0x94, 0x8b, 0xb5, 0xc4, 0xa6, 0xe0, 0xea, 0x3d, 0x71, 0xeb, + 0x54, 0xc1, 0xe8, 0x47, 0xe8, 0x94, 0x5e, 0x4c, 0xab, 0x5a, 0x6a, 0xc2, 0xed, 0xef, 0x36, 0xb1, + 0x03, 0xc6, 0x16, 0x59, 0x10, 0xc6, 0xc9, 0x35, 0xa7, 0xe5, 0xd3, 0xb0, 0x22, 0x4e, 0xfa, 0x8f, + 0x4f, 0x03, 0xef, 0xbf, 0xa7, 0x81, 0xf7, 0xe6, 0x69, 0xe0, 0xfd, 0xf9, 0x76, 0xb0, 0x71, 0xdd, + 0xb6, 0x6f, 0xf5, 0xb7, 0xef, 0x02, 0x00, 0x00, 0xff, 0xff, 0x71, 0xb9, 0x6a, 0x62, 0xdc, 0x05, + 0x00, 0x00, } func (m *Report) Marshal() (dAtA []byte, err error) { @@ -723,9 +812,9 @@ func (m *Report) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } - if m.Tiup != nil { + if m.Version != nil { { - size, err := m.Tiup.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Version.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -733,7 +822,7 @@ func (m *Report) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintReport(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } if m.EventDetail != nil { { @@ -766,6 +855,27 @@ func (m *Report) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Report_Tiup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Report_Tiup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Tiup != nil { + { + size, err := m.Tiup.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintReport(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} func (m *Report_Cluster) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) @@ -783,10 +893,64 @@ func (m *Report_Cluster) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintReport(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } return len(dAtA) - i, nil } +func (m *TiUPReport) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TiUPReport) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TiUPReport) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.CustomMirror { + i-- + if m.CustomMirror { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if m.ExitCode != 0 { + i = encodeVarintReport(dAtA, i, uint64(m.ExitCode)) + i-- + dAtA[i] = 0x18 + } + if m.TakeMilliseconds != 0 { + i = encodeVarintReport(dAtA, i, uint64(m.TakeMilliseconds)) + i-- + dAtA[i] = 0x10 + } + if len(m.Command) > 0 { + i -= len(m.Command) + copy(dAtA[i:], m.Command) + i = encodeVarintReport(dAtA, i, uint64(len(m.Command))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *ClusterReport) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1215,8 +1379,8 @@ func (m *Report) Size() (n int) { if m.EventDetail != nil { n += m.EventDetail.Size() } - if m.Tiup != nil { - l = m.Tiup.Size() + if m.Version != nil { + l = m.Version.Size() n += 1 + l + sovReport(uint64(l)) } if m.XXX_unrecognized != nil { @@ -1225,6 +1389,18 @@ func (m *Report) Size() (n int) { return n } +func (m *Report_Tiup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Tiup != nil { + l = m.Tiup.Size() + n += 1 + l + sovReport(uint64(l)) + } + return n +} func (m *Report_Cluster) Size() (n int) { if m == nil { return 0 @@ -1237,6 +1413,31 @@ func (m *Report_Cluster) Size() (n int) { } return n } +func (m *TiUPReport) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Command) + if l > 0 { + n += 1 + l + sovReport(uint64(l)) + } + if m.TakeMilliseconds != 0 { + n += 1 + sovReport(uint64(m.TakeMilliseconds)) + } + if m.ExitCode != 0 { + n += 1 + sovReport(uint64(m.ExitCode)) + } + if m.CustomMirror { + n += 2 + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *ClusterReport) Size() (n int) { if m == nil { return 0 @@ -1543,6 +1744,41 @@ func (m *Report) Unmarshal(dAtA []byte) error { } } case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tiup", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowReport + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthReport + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthReport + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &TiUPReport{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.EventDetail = &Report_Tiup{v} + iNdEx = postIndex + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Cluster", wireType) } @@ -1577,9 +1813,9 @@ func (m *Report) Unmarshal(dAtA []byte) error { } m.EventDetail = &Report_Cluster{v} iNdEx = postIndex - case 5: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tiup", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1606,10 +1842,10 @@ func (m *Report) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Tiup == nil { - m.Tiup = &TiUPInfo{} + if m.Version == nil { + m.Version = &TiUPInfo{} } - if err := m.Tiup.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Version.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1635,6 +1871,147 @@ func (m *Report) Unmarshal(dAtA []byte) error { } return nil } +func (m *TiUPReport) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowReport + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TiUPReport: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TiUPReport: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Command", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowReport + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthReport + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthReport + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Command = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TakeMilliseconds", wireType) + } + m.TakeMilliseconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowReport + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TakeMilliseconds |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExitCode", wireType) + } + m.ExitCode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowReport + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExitCode |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CustomMirror", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowReport + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.CustomMirror = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipReport(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthReport + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ClusterReport) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/pkg/telemetry/report.proto b/pkg/telemetry/report.proto index f476dc3a2c..8ad80d1637 100644 --- a/pkg/telemetry/report.proto +++ b/pkg/telemetry/report.proto @@ -9,9 +9,17 @@ message Report { int64 event_unix_timestamp = 3; // unix time second oneof event_detail { - ClusterReport cluster = 4; + TiUPReport tiup = 4; + ClusterReport cluster = 5; } - TiUPInfo tiup = 5; + TiUPInfo version = 6; +} + +message TiUPReport { + string command = 1; + uint64 take_milliseconds = 2; + int32 exit_code = 3; + bool custom_mirror = 4; } message ClusterReport { diff --git a/pkg/cluster/report/report_test.go b/pkg/telemetry/report_test.go similarity index 85% rename from pkg/cluster/report/report_test.go rename to pkg/telemetry/report_test.go index feb50f7ac9..714410ea36 100644 --- a/pkg/cluster/report/report_test.go +++ b/pkg/telemetry/report_test.go @@ -11,14 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -package report +package telemetry import ( "context" "testing" - telemetry2 "github.com/pingcap/tiup/pkg/telemetry" - "github.com/pingcap/check" ) @@ -29,8 +27,8 @@ var _ = check.Suite(&reportSuite{}) func TestT(t *testing.T) { check.TestingT(t) } func (s *reportSuite) TestNodeInfo(c *check.C) { - info := new(telemetry2.NodeInfo) - err := telemetry2.FillNodeInfo(context.Background(), info) + info := new(NodeInfo) + err := FillNodeInfo(context.Background(), info) c.Assert(err, check.IsNil) text, err := NodeInfoToText(info)