Skip to content

Commit

Permalink
Rename operation name for activator's proxy span and queue-proxy's sp…
Browse files Browse the repository at this point in the history
…an (#7934)

* 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.

* Fix unit test
  • Loading branch information
nak3 authored May 13, 2020
1 parent c4d1953 commit 6d10842
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd/queue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions cmd/queue/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand Down
2 changes: 1 addition & 1 deletion pkg/activator/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pkg/activator/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6d10842

Please sign in to comment.