From a47e3e488b21c6f3764536c94eca7ca2995e60c7 Mon Sep 17 00:00:00 2001 From: Kenjiro Nakayama Date: Wed, 13 May 2020 19:38:52 +0900 Subject: [PATCH 1/2] Rename operation name for activator's proxy span and queue-proxy's span Currently both activator's proxy span and queue-proxy's proxy span have same name `proxy`. It is alright to see one trace data. But it is difficult to find/filter it by operation name. Hence, for example, if we want to find the trace which _activator is in the path_, we cannot filter it. --- cmd/queue/main.go | 4 ++-- pkg/activator/handler/handler.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/queue/main.go b/cmd/queue/main.go index 1be09afb6577..eeee9a876856 100644 --- a/cmd/queue/main.go +++ b/cmd/queue/main.go @@ -129,7 +129,7 @@ func proxyHandler(reqChan chan network.ReqEvent, breaker *queue.Breaker, tracing } if tracingEnabled { - proxyCtx, proxySpan := trace.StartSpan(r.Context(), "proxy") + proxyCtx, proxySpan := trace.StartSpan(r.Context(), "queue_proxy") r = r.WithContext(proxyCtx) defer proxySpan.End() } @@ -149,7 +149,7 @@ func proxyHandler(reqChan chan network.ReqEvent, breaker *queue.Breaker, tracing if breaker != nil { var waitSpan *trace.Span if tracingEnabled { - _, waitSpan = trace.StartSpan(r.Context(), "queueWait") + _, waitSpan = trace.StartSpan(r.Context(), "queue_wait") } if err := breaker.Maybe(r.Context(), func() { waitSpan.End() diff --git a/pkg/activator/handler/handler.go b/pkg/activator/handler/handler.go index 41972fa53d89..d2070fdc2bf6 100644 --- a/pkg/activator/handler/handler.go +++ b/pkg/activator/handler/handler.go @@ -75,7 +75,7 @@ func (a *activationHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { proxyCtx, proxySpan := r.Context(), (*trace.Span)(nil) if tracingEnabled { - proxyCtx, proxySpan = trace.StartSpan(r.Context(), "proxy") + proxyCtx, proxySpan = trace.StartSpan(r.Context(), "activator_proxy") } a.proxyRequest(logger, w, r.WithContext(proxyCtx), &url.URL{ Scheme: "http", From c6903840ad3d77443d04d94a1a7a546dde746e9d Mon Sep 17 00:00:00 2001 From: Kenjiro Nakayama Date: Wed, 13 May 2020 20:56:40 +0900 Subject: [PATCH 2/2] Fix unit test --- cmd/queue/main_test.go | 4 ++-- pkg/activator/handler/handler_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/queue/main_test.go b/cmd/queue/main_test.go index 69ca84223aa9..8e53a65bf6a9 100644 --- a/cmd/queue/main_test.go +++ b/cmd/queue/main_test.go @@ -474,14 +474,14 @@ func TestQueueTraceSpans(t *testing.T) { if len(gotSpans) != tc.wantSpans { t.Errorf("Got %d spans, expected %d", len(gotSpans), tc.wantSpans) } - spanNames := []string{"probe", "/", "proxy"} + spanNames := []string{"probe", "/", "queue_proxy"} if !tc.probeTrace { spanNames = spanNames[1:] } // We want to add `queueWait` span only if there is possible queueing // and if the tests actually expects tracing. if !tc.infiniteCC && tc.wantSpans > 1 { - spanNames = append([]string{"queueWait"}, spanNames...) + spanNames = append([]string{"queue_wait"}, spanNames...) } gs := []string{} for i := 0; i < len(gotSpans); i++ { diff --git a/pkg/activator/handler/handler_test.go b/pkg/activator/handler/handler_test.go index d853c7d57ddd..7e64ae311ce1 100644 --- a/pkg/activator/handler/handler_test.go +++ b/pkg/activator/handler/handler_test.go @@ -266,7 +266,7 @@ func TestActivationHandlerTraceSpans(t *testing.T) { t.Errorf("Got %d spans, expected %d", len(gotSpans), tc.wantSpans) } - spanNames := []string{"throttler_try", "/", "proxy"} + spanNames := []string{"throttler_try", "/", "activator_proxy"} for i, spanName := range spanNames[0:tc.wantSpans] { if gotSpans[i].Name != spanName { t.Errorf("Got span %d named %q, expected %q", i, gotSpans[i].Name, spanName)