Package list golang-github-go-kit-kit / 9e45827
do not log "SpanContext not found in Extract carrier" as this is expected behavior if client is not instrumented Bas van Beek 5 years ago
2 changed file(s) with 2 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
1414 // ToGRPCRequest returns a grpc RequestFunc that injects an OpenTracing Span
1515 // found in `ctx` into the grpc Metadata. If no such Span can be found, the
1616 // RequestFunc is a noop.
17 //
18 // The logger is used to report errors and may be nil.
1917 func ToGRPCRequest(tracer opentracing.Tracer, logger log.Logger) func(ctx context.Context, md *metadata.MD) context.Context {
2018 return func(ctx context.Context, md *metadata.MD) context.Context {
2119 if span := opentracing.SpanFromContext(ctx); span != nil {
3331 // `operationName` accordingly. If no trace could be found in `req`, the Span
3432 // will be a trace root. The Span is incorporated in the returned Context and
3533 // can be retrieved with opentracing.SpanFromContext(ctx).
36 //
37 // The logger is used to report errors and may be nil.
3834 func FromGRPCRequest(tracer opentracing.Tracer, operationName string, logger log.Logger) func(ctx context.Context, md *metadata.MD) context.Context {
3935 return func(ctx context.Context, md *metadata.MD) context.Context {
4036 var span opentracing.Span
4137 wireContext, err := tracer.Extract(opentracing.TextMap, metadataReaderWriter{md})
42 if err != nil {
38 if err != nil && err != opentracing.ErrSpanContextNotFound {
4339 logger.Log("err", err)
4440 }
4541 span = tracer.StartSpan(operationName, ext.RPCServerOption(wireContext))
1515 // ToHTTPRequest returns an http RequestFunc that injects an OpenTracing Span
1616 // found in `ctx` into the http headers. If no such Span can be found, the
1717 // RequestFunc is a noop.
18 //
19 // The logger is used to report errors and may be nil.
2018 func ToHTTPRequest(tracer opentracing.Tracer, logger log.Logger) kithttp.RequestFunc {
2119 return func(ctx context.Context, req *http.Request) context.Context {
2220 // Try to find a Span in the Context.
5149 // `operationName` accordingly. If no trace could be found in `req`, the Span
5250 // will be a trace root. The Span is incorporated in the returned Context and
5351 // can be retrieved with opentracing.SpanFromContext(ctx).
54 //
55 // The logger is used to report errors and may be nil.
5652 func FromHTTPRequest(tracer opentracing.Tracer, operationName string, logger log.Logger) kithttp.RequestFunc {
5753 return func(ctx context.Context, req *http.Request) context.Context {
5854 // Try to join to a trace propagated in `req`.
6157 opentracing.TextMap,
6258 opentracing.HTTPHeaderTextMapCarrier(req.Header),
6359 )
64 if err != nil {
60 if err != nil && err != opentracing.ErrSpanContextNotFound {
6561 logger.Log("err", err)
6662 }
6763 span = tracer.StartSpan(operationName, ext.RPCServerOption(wireContext))