Skip to content

Commit

Permalink
ensureutf8 on all strings that are passed to tracer (#2189)
Browse files Browse the repository at this point in the history
Signed-off-by: Sandor Szücs <[email protected]>

Signed-off-by: Sandor Szücs <[email protected]>
  • Loading branch information
szuecs authored Jan 6, 2023
1 parent e441013 commit 59ed199
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ func (p *Proxy) setCommonSpanInfo(u *url.URL, r *http.Request, s ot.Span) {
setTag(s, HTTPPathTag, u.Path).
setTag(s, HTTPHostTag, r.Host)
if val := r.Header.Get("X-Flow-Id"); val != "" {
p.tracing.setTag(s, FlowIDTag, ensureUTF8(val))
p.tracing.setTag(s, FlowIDTag, val)
}
}

Expand Down
10 changes: 7 additions & 3 deletions proxy/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (t *proxyTracing) logEvent(span ot.Span, eventName, eventValue string) {
return
}

span.LogKV(eventName, eventValue)
span.LogKV(eventName, ensureUTF8(eventValue))
}

func (t *proxyTracing) setTag(span ot.Span, key string, value interface{}) *proxyTracing {
Expand All @@ -90,7 +90,11 @@ func (t *proxyTracing) setTag(span ot.Span, key string, value interface{}) *prox
}

if !t.excludeTags[key] {
span.SetTag(key, value)
if s, ok := value.(string); ok {
span.SetTag(key, ensureUTF8(s))
} else {
span.SetTag(key, value)
}
}

return t
Expand All @@ -101,7 +105,7 @@ func (t *proxyTracing) logStreamEvent(span ot.Span, eventName, eventValue string
return
}

t.logEvent(span, eventName, eventValue)
t.logEvent(span, eventName, ensureUTF8(eventValue))
}

func (t *proxyTracing) startFilterTracing(operation string, ctx *context) *filterTracing {
Expand Down

0 comments on commit 59ed199

Please sign in to comment.