Skip to content
Open
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
10 changes: 5 additions & 5 deletions tracing/opentracing/server_interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/grpc-ecosystem/go-grpc-middleware/tags"
"github.com/grpc-ecosystem/go-grpc-middleware/util/metautils"
"github.com/opentracing/opentracing-go"
opentracing "github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
"github.com/opentracing/opentracing-go/log"
"golang.org/x/net/context"
Expand All @@ -28,7 +28,7 @@ func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor {
}
newCtx, serverSpan := newServerSpanFromInbound(ctx, o.tracer, info.FullMethod)
resp, err := handler(newCtx, req)
finishServerSpan(ctx, serverSpan, err)
finishServerSpan(ctx, serverSpan, err, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets pass this via opts ... maybe something like DisableErrorTracing default to true so not to change behaviour

return resp, err
}
}
Expand All @@ -44,7 +44,7 @@ func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor {
wrappedStream := grpc_middleware.WrapServerStream(stream)
wrappedStream.WrappedContext = newCtx
err := handler(srv, wrappedStream)
finishServerSpan(newCtx, serverSpan, err)
finishServerSpan(newCtx, serverSpan, err, false)
return err
}
}
Expand All @@ -67,7 +67,7 @@ func newServerSpanFromInbound(ctx context.Context, tracer opentracing.Tracer, fu
return opentracing.ContextWithSpan(ctx, serverSpan), serverSpan
}

func finishServerSpan(ctx context.Context, serverSpan opentracing.Span, err error) {
func finishServerSpan(ctx context.Context, serverSpan opentracing.Span, err error, active bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

active > o.DisableErrorTracing?

// Log context information
tags := grpc_ctxtags.Extract(ctx)
for k, v := range tags.Values() {
Expand All @@ -79,7 +79,7 @@ func finishServerSpan(ctx context.Context, serverSpan opentracing.Span, err erro
serverSpan.SetTag(k, v)
}
}
if err != nil {
if active && err != nil {
ext.Error.Set(serverSpan, true)
serverSpan.LogFields(log.String("event", "error"), log.String("message", err.Error()))
}
Expand Down