add --trace flag

pull/9723/head
Priya Wadhwa 2020-11-16 21:39:50 -08:00
parent 0f23913f1b
commit c4dd42a1d8
3 changed files with 11 additions and 2 deletions

View File

@ -60,7 +60,7 @@ import (
"k8s.io/minikube/pkg/minikube/out/register"
"k8s.io/minikube/pkg/minikube/reason"
"k8s.io/minikube/pkg/minikube/style"
"k8s.io/minikube/pkg/trace"
pkgtrace "k8s.io/minikube/pkg/trace"
"k8s.io/minikube/pkg/minikube/registry"
"k8s.io/minikube/pkg/minikube/translate"
@ -130,7 +130,10 @@ func runStart(cmd *cobra.Command, args []string) {
register.SetEventLogPath(localpath.EventLog(ClusterFlagValue()))
out.SetJSON(outputFormat == "json")
trace.Initialize("gcp")
if err := pkgtrace.Initialize(viper.GetString(trace)); err != nil {
exit.Message(reason.Usage, "error initializing tracing: {{.Error}}", out.V{"Error": err.Error()})
}
defer pkgtrace.Cleanup()
displayVersion(version.GetVersion())
// No need to do the update check if no one is going to see it

View File

@ -108,6 +108,7 @@ const (
kicBaseImage = "base-image"
ports = "ports"
startNamespace = "namespace"
trace = "trace"
)
var (
@ -152,6 +153,7 @@ func initMinikubeFlags() {
startCmd.Flags().Bool(deleteOnFailure, false, "If set, delete the current cluster if start fails and try again. Defaults to false.")
startCmd.Flags().Bool(forceSystemd, false, "If set, force the container runtime to use sytemd as cgroup manager. Currently available for docker and crio. Defaults to false.")
startCmd.Flags().StringVarP(&outputFormat, "output", "o", "text", "Format to print stdout in. Options include: [text,json]")
startCmd.Flags().StringP(trace, "", "", "Send trace events. Options include: [gcp]")
}
// initKubernetesFlags inits the commandline flags for Kubernetes related options

View File

@ -21,6 +21,7 @@ import (
"fmt"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/trace"
)
const (
@ -117,6 +118,7 @@ func (r *Register) currentStep() string {
// SetStep sets the current step
func (r *Register) SetStep(s RegStep) {
defer trace.StartSpan(string(s))
if r.first == RegStep("") {
_, ok := r.steps[s]
if ok {
@ -124,6 +126,8 @@ func (r *Register) SetStep(s RegStep) {
} else {
klog.Errorf("unexpected first step: %q", r.first)
}
} else {
trace.EndSpan(string(r.current))
}
r.current = s