Skip to content

Commit

Permalink
Merge pull request kata-containers#483 from jodh-intel/hide-trace-mes…
Browse files Browse the repository at this point in the history
…sages-by-default

tracing: Hide trace messages unless tracing enabled
  • Loading branch information
Julio Montes authored Mar 15, 2019
2 parents 13347ed + 6bd0f7c commit 3297a0d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ func setupTracing(rootSpanName string) (opentracing.Span, context.Context, error
span.SetTag("source", "agent")
span.SetTag("root-span", "true")

agentLog.Debugf("created root span %v", span)
// See comment in trace().
if tracing {
agentLog.Debugf("created root span %v", span)
}

// Associate the root span with the context
ctx = opentracing.ContextWithSpan(ctx, span)
Expand Down Expand Up @@ -134,7 +137,12 @@ func trace(ctx context.Context, subsystem, name string) (opentracing.Span, conte

span.SetTag("subsystem", subsystem)

agentLog.Debugf("created span %v", span)
// This is slightly confusing: when tracing is disabled, trace spans
// are still created - but the tracer used is a NOP. Therefore, only
// display the message when tracing is really enabled.
if tracing {
agentLog.Debugf("created span %v", span)
}

return span, ctx
}

0 comments on commit 3297a0d

Please sign in to comment.