mirror of https://github.com/databricks/cli.git
This commit is contained in:
parent
5da92e94e3
commit
8b3d942b48
|
@ -106,7 +106,7 @@ func Execute(ctx context.Context, cmd *cobra.Command) error {
|
||||||
// TODO: deferred panic recovery
|
// TODO: deferred panic recovery
|
||||||
ctx = telemetry.WithNewLogger(ctx)
|
ctx = telemetry.WithNewLogger(ctx)
|
||||||
ctx = dbr.DetectRuntime(ctx)
|
ctx = dbr.DetectRuntime(ctx)
|
||||||
start := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
// Run the command
|
// Run the command
|
||||||
cmd, err := cmd.ExecuteContextC(ctx)
|
cmd, err := cmd.ExecuteContextC(ctx)
|
||||||
|
@ -134,14 +134,12 @@ func Execute(ctx context.Context, cmd *cobra.Command) error {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end := time.Now()
|
|
||||||
exitCode := 0
|
exitCode := 0
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exitCode = 1
|
exitCode = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadTelemetry(cmd.Context(), commandString(cmd), start, end, exitCode)
|
uploadTelemetry(cmd.Context(), commandString(cmd), startTime, exitCode)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +174,7 @@ func inheritEnvVars() []string {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func uploadTelemetry(ctx context.Context, cmdStr string, start, end time.Time, exitCode int) {
|
func uploadTelemetry(ctx context.Context, cmdStr string, startTime time.Time, exitCode int) {
|
||||||
// Nothing to upload.
|
// Nothing to upload.
|
||||||
if !telemetry.HasLogs(ctx) {
|
if !telemetry.HasLogs(ctx) {
|
||||||
return
|
return
|
||||||
|
@ -193,7 +191,7 @@ func uploadTelemetry(ctx context.Context, cmdStr string, start, end time.Time, e
|
||||||
Command: cmdStr,
|
Command: cmdStr,
|
||||||
OperatingSystem: runtime.GOOS,
|
OperatingSystem: runtime.GOOS,
|
||||||
DbrVersion: env.Get(ctx, dbr.EnvVarName),
|
DbrVersion: env.Get(ctx, dbr.EnvVarName),
|
||||||
ExecutionTimeMs: end.Sub(start).Milliseconds(),
|
ExecutionTimeMs: time.Since(startTime).Milliseconds(),
|
||||||
ExitCode: int64(exitCode),
|
ExitCode: int64(exitCode),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue