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

Commit

Permalink
tracing: Generate an alias for opentracing.Span
Browse files Browse the repository at this point in the history
We should use an alias for opentracing.Span as this can be changed in the
future when we implement other tracing methods.

Fixes #664

Signed-off-by: Gabriela Cervantes <[email protected]>
  • Loading branch information
GabyCT committed Oct 16, 2019
1 parent b90fe28 commit 455f728
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ var logsVSockPort = uint32(0)
// commType is used to denote the communication channel type used.
type commType int

// agentSpan is used to denote the span tracing that is being used.
type agentSpan opentracing.Span

const (
// virtio-serial channel
serialCh commType = iota
Expand Down Expand Up @@ -239,7 +242,7 @@ func (p *process) closePostExitFDs() {
}
}

func (c *container) trace(name string) (opentracing.Span, context.Context) {
func (c *container) trace(name string) (agentSpan, context.Context) {
if c.ctx == nil {
agentLog.WithField("type", "bug").Error("trace called before context set")
c.ctx = context.Background()
Expand Down Expand Up @@ -288,7 +291,7 @@ func (c *container) getProcess(execID string) (*process, error) {
return proc, nil
}

func (s *sandbox) trace(name string) (opentracing.Span, context.Context) {
func (s *sandbox) trace(name string) (agentSpan, context.Context) {
if s.ctx == nil {
agentLog.WithField("type", "bug").Error("trace called before context set")
s.ctx = context.Background()
Expand Down Expand Up @@ -1028,7 +1031,7 @@ func makeUnaryInterceptor() grpc.UnaryServerInterceptor {

grpcCall := info.FullMethod
var ctx context.Context
var span opentracing.Span
var span agentSpan

if tracing {
ctx = getGRPCContext()
Expand Down
6 changes: 3 additions & 3 deletions tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
)

// The first trace span
var rootSpan opentracing.Span
var rootSpan agentSpan

// Implements jaeger-client-go.Logger interface
type traceLogger struct {
Expand Down Expand Up @@ -82,7 +82,7 @@ func createTracer(name string) (opentracing.Tracer, error) {
return tracer, nil
}

func setupTracing(rootSpanName string) (opentracing.Span, context.Context, error) {
func setupTracing(rootSpanName string) (agentSpan, context.Context, error) {
ctx := context.Background()

tracer, err := createTracer(agentName)
Expand Down Expand Up @@ -132,7 +132,7 @@ func stopTracing(ctx context.Context) {

// trace creates a new tracing span based on the specified contex, subsystem
// and name.
func trace(ctx context.Context, subsystem, name string) (opentracing.Span, context.Context) {
func trace(ctx context.Context, subsystem, name string) (agentSpan, context.Context) {
span, ctx := opentracing.StartSpanFromContext(ctx, name)

span.SetTag("subsystem", subsystem)
Expand Down

0 comments on commit 455f728

Please sign in to comment.