* Define and use an interface for logging. This allows alternative implementations to use whatever logging package they want. Currently the interface just mimicks what logrus already implements, with minor modifications to not rely on logrus itself. I think the interface is pretty solid in terms of logging implementations being able to do what they need to. * Make tracing interface to coalesce logging/tracing Allows us to share data between the tracer and the logger so we can simplify log/trace handling wher we generally want data to go both places.
24 lines
617 B
Go
24 lines
617 B
Go
package trace
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/virtual-kubelet/virtual-kubelet/log"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
type nopTracer struct{}
|
|
|
|
func (nopTracer) StartSpan(ctx context.Context, _ string) (context.Context, Span) {
|
|
return ctx, &nopSpan{}
|
|
}
|
|
|
|
type nopSpan struct{}
|
|
|
|
func (nopSpan) End() {}
|
|
func (nopSpan) SetStatus(trace.Status) {}
|
|
func (nopSpan) Logger() log.Logger { return nil }
|
|
|
|
func (nopSpan) WithField(ctx context.Context, _ string, _ interface{}) context.Context { return ctx }
|
|
func (nopSpan) WithFields(ctx context.Context, _ log.Fields) context.Context { return ctx }
|