Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 91a668a

Browse files
authored
Merge pull request #641 from docker/fix_metrics_default_context
In metrics, send context type, not context name (metrics for Moby calls)
2 parents 64cd8eb + 8302266 commit 91a668a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cli/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ $ docker context create %s <name>`, cc.Type(), store.EcsContextType), ctype)
209209
}
210210
mobycli.ExecIfDefaultCtxType(ctx, root)
211211

212-
checkIfUnknownCommandExistInDefaultContext(err, currentContext, root)
212+
checkIfUnknownCommandExistInDefaultContext(err, currentContext, root, ctype)
213213

214214
exit(root, currentContext, err, ctype)
215215
}
@@ -242,14 +242,14 @@ func fatal(err error) {
242242
os.Exit(1)
243243
}
244244

245-
func checkIfUnknownCommandExistInDefaultContext(err error, currentContext string, root *cobra.Command) {
245+
func checkIfUnknownCommandExistInDefaultContext(err error, currentContext string, root *cobra.Command, contextType string) {
246246
submatch := unknownCommandRegexp.FindSubmatch([]byte(err.Error()))
247247
if len(submatch) == 2 {
248248
dockerCommand := string(submatch[1])
249249

250250
if mobycli.IsDefaultContextCommand(dockerCommand) {
251251
fmt.Fprintf(os.Stderr, "Command %q not available in current context (%s), you can use the \"default\" context to run this command\n", dockerCommand, currentContext)
252-
metrics.Track(currentContext, os.Args[1:], root.PersistentFlags(), metrics.FailureStatus)
252+
metrics.Track(contextType, os.Args[1:], root.PersistentFlags(), metrics.FailureStatus)
253253
os.Exit(1)
254254
}
255255
}

cli/mobycli/exec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ func Exec(root *cobra.Command) {
8686
err := cmd.Run()
8787
childExit <- true
8888
if err != nil {
89-
metrics.Track(store.DefaultContextName, os.Args[1:], root.PersistentFlags(), metrics.FailureStatus)
89+
metrics.Track(store.DefaultContextType, os.Args[1:], root.PersistentFlags(), metrics.FailureStatus)
9090

9191
if exiterr, ok := err.(*exec.ExitError); ok {
9292
os.Exit(exiterr.ExitCode())
9393
}
9494
fmt.Fprintln(os.Stderr, err)
9595
os.Exit(1)
9696
}
97-
metrics.Track(store.DefaultContextName, os.Args[1:], root.PersistentFlags(), metrics.SuccessStatus)
97+
metrics.Track(store.DefaultContextType, os.Args[1:], root.PersistentFlags(), metrics.SuccessStatus)
9898

9999
os.Exit(0)
100100
}

0 commit comments

Comments
 (0)