grpc-ecosystem / grpc-opentracing

OpenTracing is a set of consistent, expressive, vendor-neutral APIs for distributed tracing and context propagation
BSD 3-Clause "New" or "Revised" License
472 stars 98 forks source link

[Go] how to get remote address in SpanDecoratorFunc #35

Open NeoCN opened 7 years ago

NeoCN commented 7 years ago

I notice that there is SpanDecoratorFunc to use, and I want to add peer.Address Tag in both client and server span, according to the doc

// SpanDecoratorFunc provides an (optional) mechanism for otgrpc users to add
// arbitrary tags/logs/etc to the opentracing.Span associated with client
// and/or server RPCs.
type SpanDecoratorFunc func(
    span opentracing.Span,
    method string,
    req, resp interface{},
    grpcError error)

How can I get remote address without context.Context or peer.Peer as argument?

marcwilson-g commented 6 years ago

I have a similar issue wanting to decorate the Span based on the existence of a metadata attribute (specifically I want to include the value from "x-retry-attempty" to indicate that the gRPC request is a retry initiated by go-grpc-middleware/retry) I could put a pull request together that adds context into SpanDecoratorFunc, but that would be an API breaking change. Alternative approaches would involve adding additional Options to extend the OpenTracingClientInterceptor