fix: use DurationFlag to response-threshold (#4227)
Also add missing flags from 'mc admin scanner trace'
This commit is contained in:
@@ -28,6 +28,10 @@ import (
|
||||
)
|
||||
|
||||
var adminScannerTraceFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "verbose, v",
|
||||
Usage: "print verbose trace",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "response-threshold",
|
||||
Usage: "trace calls only with response duration greater than this threshold (e.g. `5ms`)",
|
||||
@@ -40,6 +44,10 @@ var adminScannerTraceFlags = []cli.Flag{
|
||||
Name: "node",
|
||||
Usage: "trace only matching servers",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "path",
|
||||
Usage: "trace only matching path",
|
||||
},
|
||||
}
|
||||
|
||||
var adminScannerTraceCmd = cli.Command{
|
||||
@@ -73,7 +81,7 @@ EXAMPLES:
|
||||
|
||||
func checkAdminScannerTraceSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "trace", 1) // last argument is exit code
|
||||
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-9
@@ -49,7 +49,7 @@ var adminTraceFlags = []cli.Flag{
|
||||
Name: "call",
|
||||
Usage: "trace only matching Call types (values: `s3`, `internal`, `storage`, `os`, `scanner`, `decommission`)",
|
||||
},
|
||||
cli.StringFlag{
|
||||
cli.DurationFlag{
|
||||
Name: "response-threshold",
|
||||
Usage: "trace calls only with response duration greater than this threshold (e.g. `5ms`)",
|
||||
},
|
||||
@@ -218,15 +218,8 @@ func matchTrace(opts matchOpts, traceInfo madmin.ServiceTraceInfo) bool {
|
||||
|
||||
// Calculate tracing options for command line flags
|
||||
func tracingOpts(ctx *cli.Context, apis []string) (opts madmin.ServiceTraceOpts, e error) {
|
||||
if t := ctx.String("response-threshold"); t != "" {
|
||||
d, e := time.ParseDuration(t)
|
||||
if e != nil {
|
||||
return opts, fmt.Errorf("Unable to parse threshold argument: %w", e)
|
||||
}
|
||||
opts.Threshold = d
|
||||
}
|
||||
|
||||
opts.OnlyErrors = ctx.Bool("errors")
|
||||
opts.Threshold = ctx.Duration("response-threshold")
|
||||
|
||||
if ctx.Bool("all") {
|
||||
opts.S3 = true
|
||||
|
||||
Reference in New Issue
Block a user