gogf / gf

GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang.
https://goframe.org
MIT License
11.79k stars 1.61k forks source link

net/gclient: gclient downloads pictures, causing observable reporting. The tracingEventHttpResponseBody body is not utf8, causing tracking loss. #3791

Closed ivothgle closed 2 months ago

ivothgle commented 2 months ago

Go version

1.22

GoFrame version

2.7.0

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

开启链路跟踪

g.Client().GetBytes(ctx, "http://a.com/jpg")

然后就报 string field contains invalid UTF-8 了

主要原因是这里获取到了非文本内容导致的

resBodyContent, err := gtrace.SafeContentForHttp(reqBodyContentBytes, response.Header)
if err != nil {
    span.SetStatus(codes.Error, fmt.Sprintf(`converting safe content failed: %s`, err.Error()))
}

What did you see happen?

希望可以提供自定义修改或忽略

What did you expect to see?

然后就报 string field contains invalid UTF-8 了

gqcn commented 2 months ago

@ivothgle Thanks for you feedback, I'll have a check for this.