Add trace support for decommissioning (#4195)

This commit is contained in:
Krishnan Parthasarathi
2022-08-10 10:14:21 -07:00
committed by GitHub
parent c307963422
commit d691fc4c9f
3 changed files with 34 additions and 17 deletions
+31 -14
View File
@@ -47,7 +47,7 @@ var adminTraceFlags = []cli.Flag{
},
cli.StringSliceFlag{
Name: "call",
Usage: "trace only matching Call types (values: `s3`, `internal`, `storage`, `os`, 'scanner')",
Usage: "trace only matching Call types (values: `s3`, `internal`, `storage`, `os`, `scanner`, `decommission`)",
},
cli.StringFlag{
Name: "response-threshold",
@@ -234,6 +234,7 @@ func tracingOpts(ctx *cli.Context, apis []string) (opts madmin.ServiceTraceOpts,
opts.Storage = true
opts.OS = true
opts.Scanner = true
opts.Decommission = true
return
}
@@ -256,6 +257,8 @@ func tracingOpts(ctx *cli.Context, apis []string) (opts madmin.ServiceTraceOpts,
opts.OS = true
case "scanner":
opts.Scanner = true
case "decom", "decommission":
opts.Decommission = true
}
}
@@ -336,8 +339,8 @@ type shortTraceMsg struct {
StatusCode int `json:"statusCode"`
StatusMsg string `json:"statusMsg"`
Type string `json:"type"`
trcType madmin.TraceType
Error string `json:"error"`
trcType madmin.TraceType
}
type traceMessage struct {
@@ -372,12 +375,12 @@ type callStats struct {
type verboseTrace struct {
Type string `json:"type"`
NodeName string `json:"host"`
FuncName string `json:"api"`
Time time.Time `json:"time"`
Duration time.Duration `json:"duration"`
Path string `json:"path"`
NodeName string `json:"host"`
FuncName string `json:"api"`
Time time.Time `json:"time"`
Duration time.Duration `json:"duration"`
Path string `json:"path"`
Error string `json:"error"`
RequestInfo *requestInfo `json:"request,omitempty"`
ResponseInfo *responseInfo `json:"response,omitempty"`
CallStats *callStats `json:"callStats,omitempty"`
@@ -395,6 +398,7 @@ func shortTrace(ti madmin.ServiceTraceInfo) shortTraceMsg {
s.FuncName = t.FuncName
s.Time = t.Time
s.Path = t.Path
s.Error = t.Error
s.Host = t.NodeName
s.Duration = t.Duration
@@ -436,10 +440,18 @@ func (s shortTraceMsg) String() string {
switch s.trcType {
case madmin.TraceS3, madmin.TraceInternal:
default:
fmt.Fprintf(b, "[%s] %s %s %s %2s", console.Colorize("RespStatus", strings.ToUpper(s.trcType.String())), console.Colorize("FuncName", s.FuncName),
hostStr,
s.Path,
console.Colorize("HeaderValue", s.Duration))
if s.Error != "" {
fmt.Fprintf(b, "[%s] %s %s %s err='%s' %2s", console.Colorize("RespStatus", strings.ToUpper(s.trcType.String())), console.Colorize("FuncName", s.FuncName),
hostStr,
s.Path,
console.Colorize("ErrStatus", s.Error),
console.Colorize("HeaderValue", s.Duration))
} else {
fmt.Fprintf(b, "[%s] %s %s %s %2s", console.Colorize("RespStatus", strings.ToUpper(s.trcType.String())), console.Colorize("FuncName", s.FuncName),
hostStr,
s.Path,
console.Colorize("HeaderValue", s.Duration))
}
return b.String()
}
@@ -491,6 +503,7 @@ func (t traceMessage) JSON() string {
Time: t.Trace.Time,
Duration: t.Trace.Duration,
Path: t.Trace.Path,
Error: t.Trace.Error,
}
if t.Trace.HTTP != nil {
@@ -556,7 +569,11 @@ func (t traceMessage) String() string {
return ""
}
default:
fmt.Fprintf(b, "%s %s [%s] %s %s", nodeNameStr, console.Colorize("Request", fmt.Sprintf("[%s %s]", strings.ToUpper(trc.TraceType.String()), trc.FuncName)), trc.Time.Local().Format(traceTimeFormat), trc.Path, trc.Duration)
if trc.Error != "" {
fmt.Fprintf(b, "%s %s [%s] %s err='%s' %s", nodeNameStr, console.Colorize("Request", fmt.Sprintf("[%s %s]", strings.ToUpper(trc.TraceType.String()), trc.FuncName)), trc.Time.Local().Format(traceTimeFormat), trc.Path, console.Colorize("ErrStatus", trc.Error), trc.Duration)
} else {
fmt.Fprintf(b, "%s %s [%s] %s %s", nodeNameStr, console.Colorize("Request", fmt.Sprintf("[%s %s]", strings.ToUpper(trc.TraceType.String()), trc.FuncName)), trc.Time.Local().Format(traceTimeFormat), trc.Path, trc.Duration)
}
return b.String()
}
+1 -1
View File
@@ -19,7 +19,7 @@ require (
github.com/minio/cli v1.22.0
github.com/minio/colorjson v1.0.2
github.com/minio/filepath v1.0.0
github.com/minio/madmin-go v1.4.12
github.com/minio/madmin-go v1.4.15
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/minio-go/v7 v7.0.31
github.com/minio/pkg v1.2.0
+2 -2
View File
@@ -341,8 +341,8 @@ github.com/minio/colorjson v1.0.2/go.mod h1:JWxcL2n8T8JVf+NY6awl6kn5nK49aAzHOeQE
github.com/minio/filepath v1.0.0 h1:fvkJu1+6X+ECRA6G3+JJETj4QeAYO9sV43I79H8ubDY=
github.com/minio/filepath v1.0.0/go.mod h1:/nRZA2ldl5z6jT9/KQuvZcQlxZIMQoFFQPvEXx9T/Bw=
github.com/minio/madmin-go v1.3.5/go.mod h1:vGKGboQgGIWx4DuDUaXixjlIEZOCIp6ivJkQoiVaACc=
github.com/minio/madmin-go v1.4.12 h1:2jr4QLoJOXkwxpPPSbriopZJ3ExyO4TwF/j57pE6dVQ=
github.com/minio/madmin-go v1.4.12/go.mod h1:ez87VmMtsxP7DRxjKJKD4RDNW+nhO2QF9KSzwxBDQ98=
github.com/minio/madmin-go v1.4.15 h1:1uqNMLa2ZhU05FIxPW8bUmZ5Orbs+6Tmj5B2LFJsdRI=
github.com/minio/madmin-go v1.4.15/go.mod h1:ez87VmMtsxP7DRxjKJKD4RDNW+nhO2QF9KSzwxBDQ98=
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=