Skip to content

Commit

Permalink
fix: we leak vars to func scope where if scope is enough (#1636)
Browse files Browse the repository at this point in the history
* fix: we leak vars to func scope where if scope is enough

Signed-off-by: Sandor Szücs <[email protected]>

* we need to define err later

Signed-off-by: Sandor Szücs <[email protected]>
  • Loading branch information
szuecs authored Dec 8, 2020
1 parent 8a8334f commit 9130fa5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9130fa5

Please sign in to comment.