Skip to content

Commit

Permalink
Add filter to --trace flag to filter by application or minio (#50)
Browse files Browse the repository at this point in the history
internal requests or `all`.
  • Loading branch information
poornas authored Jan 7, 2021
1 parent 9cee4e4 commit ccfed77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion http-tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,11 @@ func displayTrace(trace TraceInfo, backend *Backend) {
st := shortTrace(trace)
backend.updateCallStats(st)

if globalQuietEnabled || !globalTraceEnabled {
if globalQuietEnabled || globalTrace == "" {
return
}

if globalTrace == "minio" && st.Path != "/minio/health/ready" {
return
}
if globalJSONEnabled {
Expand Down
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var (
globalQuietEnabled bool
globalDebugEnabled bool
globalLoggingEnabled bool
globalTraceEnabled bool
globalTrace string
globalJSONEnabled bool
globalConsoleDisplay bool
globalConnStats []*ConnStats
Expand Down Expand Up @@ -285,7 +285,7 @@ func (b *Backend) healthCheck() {
b.Stats.DowntimeStart = time.Time{}
b.setOnline()
}
if globalTraceEnabled {
if globalTrace == "all" || globalTrace == "minio" {
if resp != nil {
httpInternalTrace(req, resp, reqTime, respTime, b)
}
Expand Down Expand Up @@ -593,10 +593,10 @@ func sidekickMain(ctx *cli.Context) {
healthCheckDuration := ctx.GlobalInt("health-duration")
addr := ctx.GlobalString("address")
globalLoggingEnabled = ctx.GlobalBool("log")
globalTraceEnabled = ctx.GlobalBool("trace")
globalTrace = ctx.GlobalString("trace")
globalJSONEnabled = ctx.GlobalBool("json")
globalQuietEnabled = ctx.GlobalBool("quiet")
globalConsoleDisplay = globalLoggingEnabled || globalTraceEnabled || !terminal.IsTerminal(int(os.Stdout.Fd()))
globalConsoleDisplay = globalLoggingEnabled || ctx.IsSet("trace") || !terminal.IsTerminal(int(os.Stdout.Fd()))
globalDebugEnabled = ctx.GlobalBool("debug")

if !strings.HasPrefix(healthCheckPath, slashSeparator) {
Expand Down Expand Up @@ -674,9 +674,9 @@ func main() {
Name: "log, l",
Usage: "enable logging",
},
cli.BoolFlag{
cli.StringFlag{
Name: "trace, t",
Usage: "enable request tracing",
Usage: "enable request tracing - valid values are [all,application,minio]",
},
cli.BoolFlag{
Name: "quiet, q",
Expand Down

0 comments on commit ccfed77

Please sign in to comment.