Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

tracing: Hide trace messages unless tracing enabled #483

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}