diff --git a/middleware/tracing/statsHandler.go b/middleware/tracing/statshandler.go similarity index 86% rename from middleware/tracing/statsHandler.go rename to middleware/tracing/statshandler.go index 594be9e12..39598f1d4 100644 --- a/middleware/tracing/statsHandler.go +++ b/middleware/tracing/statshandler.go @@ -31,9 +31,9 @@ func (c *ClientHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) { if !ok { return } - remoteAddr := p.Addr.String() - if span := trace.SpanFromContext(ctx); span.SpanContext().IsValid() { - span.SetAttributes(peerAttr(remoteAddr)...) + span := trace.SpanFromContext(ctx) + if span.SpanContext().IsValid() { + span.SetAttributes(peerAttr(p.Addr.String())...) } } diff --git a/middleware/tracing/statsHandler_test.go b/middleware/tracing/statshandler_test.go similarity index 92% rename from middleware/tracing/statsHandler_test.go rename to middleware/tracing/statshandler_test.go index ec7ea06aa..655cfe63a 100644 --- a/middleware/tracing/statsHandler_test.go +++ b/middleware/tracing/statshandler_test.go @@ -18,7 +18,7 @@ func TestClient_HandleConn(_ *testing.T) { (&ClientHandler{}).HandleConn(context.Background(), nil) } -func Test_Client_TagConn(t *testing.T) { +func TestClient_TagConn(t *testing.T) { client := &ClientHandler{} ctx := context.WithValue(context.Background(), testKey, 123) @@ -27,7 +27,7 @@ func Test_Client_TagConn(t *testing.T) { } } -func Test_Client_TagRPC(t *testing.T) { +func TestClient_TagRPC(t *testing.T) { client := &ClientHandler{} ctx := context.WithValue(context.Background(), testKey, 123) @@ -36,12 +36,10 @@ func Test_Client_TagRPC(t *testing.T) { } } -type ( - mockSpan struct { - trace.Span - mockSpanCtx *trace.SpanContext - } -) +type mockSpan struct { + trace.Span + mockSpanCtx *trace.SpanContext +} func (m *mockSpan) SpanContext() trace.SpanContext { return *m.mockSpanCtx