From 59ed199553f301cdc709d61e8c57dc9384adb41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandor=20Sz=C3=BCcs?= Date: Fri, 6 Jan 2023 16:35:48 +0100 Subject: [PATCH] ensureutf8 on all strings that are passed to tracer (#2189) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sandor Szücs Signed-off-by: Sandor Szücs --- proxy/proxy.go | 2 +- proxy/tracing.go | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 862a276a04..65923f39e6 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -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) } } diff --git a/proxy/tracing.go b/proxy/tracing.go index 3cafde2128..66b481c8f3 100644 --- a/proxy/tracing.go +++ b/proxy/tracing.go @@ -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 { @@ -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 @@ -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 {