Skip to content

Commit

Permalink
Merge pull request #9856 from priyawadhwa/dont-fail
Browse files Browse the repository at this point in the history
metrics script: don't fail if one container runtime fails
  • Loading branch information
priyawadhwa authored Dec 4, 2020
2 parents 114faa7 + ab1d2e4 commit b2e6f21
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions hack/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,35 @@ func execute() error {
return errors.Wrap(err, "registering view")
}
for _, cr := range []string{"docker", "containerd", "crio"} {
sd, err := getExporter(projectID, cr)
if err != nil {
return errors.Wrap(err, "getting stackdriver exporter")
if err := exportMinikubeStart(ctx, projectID, cr); err != nil {
log.Printf("error exporting minikube start data for runtime %v: %v", cr, err)
}
// Register it as a trace exporter
trace.RegisterExporter(sd)
}
return nil
}

if err := sd.StartMetricsExporter(); err != nil {
return errors.Wrap(err, "starting metric exporter")
}
// track minikube start time and record it to metrics collector
st, err := minikubeStartTime(ctx, projectID, tmpFile, cr)
if err != nil {
return errors.Wrap(err, "collecting start time")
}
fmt.Printf("Latency: %f\n", st)
stats.Record(ctx, latencyS.M(st))
time.Sleep(30 * time.Second)
sd.Flush()
sd.StopMetricsExporter()
trace.UnregisterExporter(sd)
func exportMinikubeStart(ctx context.Context, projectID, containerRuntime string) error {
sd, err := getExporter(projectID, containerRuntime)
if err != nil {
return errors.Wrap(err, "getting stackdriver exporter")
}
// Register it as a trace exporter
trace.RegisterExporter(sd)

if err := sd.StartMetricsExporter(); err != nil {
return errors.Wrap(err, "starting metric exporter")
}
// track minikube start time and record it to metrics collector
st, err := minikubeStartTime(ctx, projectID, tmpFile, containerRuntime)
if err != nil {
return errors.Wrap(err, "collecting start time")
}
fmt.Printf("Latency: %f\n", st)
stats.Record(ctx, latencyS.M(st))
time.Sleep(30 * time.Second)
sd.Flush()
sd.StopMetricsExporter()
trace.UnregisterExporter(sd)
return nil
}

Expand Down

0 comments on commit b2e6f21

Please sign in to comment.