Add full list of call types. (#4401)

This commit is contained in:
Klaus Post
2022-12-12 11:13:00 -08:00
committed by GitHub
parent c4c0547a57
commit c18faa5ff6
+66 -33
View File
@@ -24,6 +24,7 @@ import (
"hash/fnv"
"net/http"
"path"
"sort"
"strings"
"time"
@@ -47,7 +48,7 @@ var adminTraceFlags = []cli.Flag{
},
cli.StringSliceFlag{
Name: "call",
Usage: "trace only matching call types (e.g. `s3`, `internal`, `storage`, `os`, `scanner`, `decommission`, `healing`)",
Usage: "trace only matching call types. See CALL TYPES below for list. (default: s3)",
},
cli.DurationFlag{
Name: "response-threshold",
@@ -83,6 +84,57 @@ var adminTraceFlags = []cli.Flag{
},
}
// traceCallTypes contains all call types and flags to apply when selected.
var traceCallTypes = map[string]func(o *madmin.ServiceTraceOpts) (help string){
"storage": func(o *madmin.ServiceTraceOpts) string { o.Storage = true; return "Trace Storage calls" },
"internal": func(o *madmin.ServiceTraceOpts) string { o.Internal = true; return "Trace Internal RPC calls" },
"s3": func(o *madmin.ServiceTraceOpts) string { o.S3 = true; return "Trace S3 API calls" },
"os": func(o *madmin.ServiceTraceOpts) string { o.OS = true; return "Trace Operating System calls" },
"healing": func(o *madmin.ServiceTraceOpts) string {
o.Healing = true
return "Trace Healing operations (alias: heal)"
},
"batch-replication": func(o *madmin.ServiceTraceOpts) string {
o.BatchReplication = true
return "Trace Batch Replication (alias: brep)"
},
"decommission": func(o *madmin.ServiceTraceOpts) string {
o.Decommission = true
return "Trace Decommission operations (alias: decom)"
},
"rebalance": func(o *madmin.ServiceTraceOpts) string {
o.Rebalance = true
return "Trace Server Pool Rebalancing operations"
},
"replication-resync": func(o *madmin.ServiceTraceOpts) string {
o.ReplicationResync = true
return "Trace Replication Resync operations (alias: resync)"
},
}
// traceCallTypes contains aliases (short versions) of
var traceCallTypeAliases = map[string]func(o *madmin.ServiceTraceOpts) string{
"heal": traceCallTypes["healing"],
"decom": traceCallTypes["decommission"],
"resync": traceCallTypes["replication-resync"],
"brep": traceCallTypes["batch-replication"],
}
func traceCallsHelp() string {
var help []string
o := madmin.ServiceTraceOpts{}
const padkeyLen = 19
for k, fn := range traceCallTypes {
pad := ""
if len(k) < padkeyLen {
pad = strings.Repeat(" ", padkeyLen-len(k))
}
help = append(help, fmt.Sprintf(" %s: %s%s", k, pad, fn(&o)))
}
sort.Strings(help)
return strings.Join(help, "\n")
}
var adminTraceCmd = cli.Command{
Name: "trace",
Usage: "show http trace for MinIO server",
@@ -100,6 +152,10 @@ USAGE:
FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}
CALL TYPES:
` + traceCallsHelp() + `
EXAMPLES:
1. Show verbose console trace for MinIO server
{{.Prompt}} {{.HelpName}} -v -a myminio
@@ -275,16 +331,9 @@ func tracingOpts(ctx *cli.Context, apis []string) (opts madmin.ServiceTraceOpts,
opts.OnlyErrors = ctx.Bool("errors")
if ctx.Bool("all") {
opts.S3 = true
opts.Internal = true
opts.Storage = true
opts.OS = true
opts.Scanner = true
opts.Decommission = true
opts.Healing = true
opts.BatchReplication = true
opts.ReplicationResync = true
return
for _, fn := range traceCallTypes {
fn(&opts)
}
}
if len(apis) == 0 {
@@ -295,30 +344,14 @@ func tracingOpts(ctx *cli.Context, apis []string) (opts madmin.ServiceTraceOpts,
}
for _, api := range apis {
switch api {
case "storage":
opts.Storage = true
case "internal":
opts.Internal = true
case "s3":
opts.S3 = true
case "os":
opts.OS = true
case "scanner":
opts.Scanner = true
case "heal", "healing":
opts.Healing = true
case "decom", "decommission":
opts.Decommission = true
case "batch-replication":
opts.BatchReplication = true
case "rebalance":
opts.Rebalance = true
case "replication-resync":
opts.ReplicationResync = true
default:
fn, ok := traceCallTypes[api]
if !ok {
fn, ok = traceCallTypeAliases[api]
}
if !ok {
return madmin.ServiceTraceOpts{}, fmt.Errorf("unknown call name: `%s`", api)
}
fn(&opts)
}
return
}