From f03f5f89881ffa038265987a5830aeadbcfa7a87 Mon Sep 17 00:00:00 2001 From: jessetang <1430482733@qq.com> Date: Sun, 26 Mar 2023 22:54:30 +0800 Subject: [PATCH] fix(middleware/tracing): golang filename modify (#2727) --- .../tracing/{statsHandler.go => statshandler.go} | 6 +++--- .../{statsHandler_test.go => statshandler_test.go} | 14 ++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) rename middleware/tracing/{statsHandler.go => statshandler.go} (86%) rename middleware/tracing/{statsHandler_test.go => statshandler_test.go} (92%) 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