From 7c5b35d20f590f221ee2db979fc96494ae9960a0 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 27 Mar 2021 13:19:14 -0700 Subject: [PATCH] trace: enhance trace experience further --- cmd/http-tracer.go | 24 ++++++++++++++++++------ cmd/os-instrumented.go | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/cmd/http-tracer.go b/cmd/http-tracer.go index 574859971..db70440e4 100644 --- a/cmd/http-tracer.go +++ b/cmd/http-tracer.go @@ -130,10 +130,15 @@ func WebTrace(ri *jsonrpc.RequestInfo) trace.Info { if globalIsDistErasure { t.NodeName = globalLocalNodeName } + if t.NodeName == "" { + t.NodeName = globalLocalNodeName + } - // strip port from the host address - if host, _, err := net.SplitHostPort(t.NodeName); err == nil { - t.NodeName = host + // strip only standard port from the host address + if host, port, err := net.SplitHostPort(t.NodeName); err == nil { + if port == "443" || port == "80" { + t.NodeName = host + } } vars := mux.Vars(r) @@ -196,9 +201,16 @@ func Trace(f http.HandlerFunc, logBody bool, w http.ResponseWriter, r *http.Requ if globalIsDistErasure { t.NodeName = globalLocalNodeName } - // strip port from the host address - if host, _, err := net.SplitHostPort(t.NodeName); err == nil { - t.NodeName = host + + if t.NodeName == "" { + t.NodeName = globalLocalNodeName + } + + // strip only standard port from the host address + if host, port, err := net.SplitHostPort(t.NodeName); err == nil { + if port == "443" || port == "80" { + t.NodeName = host + } } rq := trace.RequestInfo{ diff --git a/cmd/os-instrumented.go b/cmd/os-instrumented.go index 5048ff2fa..8c55be898 100644 --- a/cmd/os-instrumented.go +++ b/cmd/os-instrumented.go @@ -66,7 +66,7 @@ func updateOSMetrics(s osMetric, paths ...string) func() { return func() { duration := time.Since(startTime) - globalTrace.Publish(osTrace(s, startTime, duration, strings.Join(paths, " "))) + globalTrace.Publish(osTrace(s, startTime, duration, strings.Join(paths, " -> "))) } }