Codebase list golang-github-go-kit-kit / b6b9c31
tracing/zipkin: use idiomatic next endpoint.Endpoint Peter Bourgon 8 years ago
1 changed file(s) with 4 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
5353 // and submits the span to the collector. If no span is found in the context,
5454 // a new span is generated and inserted.
5555 func AnnotateServer(newSpan NewSpanFunc, c Collector) endpoint.Middleware {
56 return func(e endpoint.Endpoint) endpoint.Endpoint {
56 return func(next endpoint.Endpoint) endpoint.Endpoint {
5757 return func(ctx context.Context, request interface{}) (interface{}, error) {
5858 span, ok := fromContext(ctx)
5959 if !ok {
6262 }
6363 span.Annotate(ServerReceive)
6464 defer func() { span.Annotate(ServerSend); c.Collect(span) }()
65 return e(ctx, request)
65 return next(ctx, request)
6666 }
6767 }
6868 }
7373 // collector. If no span is found in the context, a new span is generated and
7474 // inserted.
7575 func AnnotateClient(newSpan NewSpanFunc, c Collector) endpoint.Middleware {
76 return func(e endpoint.Endpoint) endpoint.Endpoint {
76 return func(next endpoint.Endpoint) endpoint.Endpoint {
7777 return func(ctx context.Context, request interface{}) (interface{}, error) {
7878 var clientSpan *Span
7979 parentSpan, ok := fromContext(ctx)
8686 defer func() { ctx = context.WithValue(ctx, SpanContextKey, parentSpan) }() // reset
8787 clientSpan.Annotate(ClientSend)
8888 defer func() { clientSpan.Annotate(ClientReceive); c.Collect(clientSpan) }()
89 return e(ctx, request)
89 return next(ctx, request)
9090 }
9191 }
9292 }