From 9130fa5f95469a0bc7e30cce6edbcf1a7092e448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandor=20Sz=C3=BCcs?= Date: Tue, 8 Dec 2020 20:25:23 +0100 Subject: [PATCH] fix: we leak vars to func scope where if scope is enough (#1636) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: we leak vars to func scope where if scope is enough Signed-off-by: Sandor Szücs * we need to define err later Signed-off-by: Sandor Szücs --- proxy/proxy.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index aa5fd8d2f4..de53c0a618 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -1340,12 +1340,10 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { var ctx *context var span ot.Span - wireContext, err := p.tracing.tracer.Extract(ot.HTTPHeaders, ot.HTTPHeadersCarrier(r.Header)) - if err == nil { - span = p.tracing.tracer.StartSpan(p.tracing.initialOperationName, ext.RPCServerOption(wireContext)) - } else { + if wireContext, err := p.tracing.tracer.Extract(ot.HTTPHeaders, ot.HTTPHeadersCarrier(r.Header)); err != nil { span = p.tracing.tracer.StartSpan(p.tracing.initialOperationName) - err = nil + } else { + span = p.tracing.tracer.StartSpan(p.tracing.initialOperationName, ext.RPCServerOption(wireContext)) } defer func() { if ctx != nil && ctx.proxySpan != nil { @@ -1407,7 +1405,7 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { } }() - err = p.do(ctx) + err := p.do(ctx) if err != nil { p.tracing.setTag(span, ErrorTag, true)