-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Panic after upgrade v3.34.0 to v3.37.1 #248
Comments
能给多一点信息吗?用法和完整堆栈 |
堆栈很长,大部分是业务相关的,稍微完整一点的如下:
|
看起来是用了client中间件,具体怎么用的?能否构造跟业务无关的可复现代码贴出来? |
我看了一下代码,应该是req.URL之前不是nil,现在变成nil了。是不是改成RawURL就行了? // SetReqClientTracer 为req的http客户端添加tracer
func SetReqClientTracer(c *req.Client, tracer trace.Tracer) {
c.WrapRoundTripFunc(func(rt req.RoundTripper) req.RoundTripFunc {
return func(req *req.Request) (resp *req.Response, err error) {
ctx := req.Context()
apiName, ok := ctx.Value(ApiNameKey).(string)
if !ok {
apiName = req.URL.Path
}
_, span := tracer.Start(req.Context(), apiName)
defer span.End()
span.SetAttributes(
attribute.String("http.url", req.URL.String()),
attribute.String("http.method", req.Method),
attribute.String("http.req.header", req.HeaderToString()),
)
//如果body不太大的话,记录下来
if len(req.Body) > 0 && len(req.Body) < 10240 {
span.SetAttributes(
attribute.String("http.req.body", string(req.Body)),
)
}
tc.Inject(ctx, propagation.HeaderCarrier(req.Headers))
resp, err = rt.RoundTrip(req)
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
}
if resp.Response != nil {
span.SetAttributes(
attribute.Int("http.status_code", resp.StatusCode),
attribute.String("http.resp.header", resp.HeaderToString()),
attribute.String("http.resp.body", resp.String()),
)
}
return
}
})
} |
确实是新版引入的,已修复 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
没有太多时间定位,直接回滚了。问题应该是:
github.com/imroc/req/v3.RoundTripFunc.RoundTrip(0x20?, 0x14bc700?)
C:/Users/taira/go/pkg/mod/github.com/imroc/req/v3@v3.37.1/client.go:1457 +0x1f
导致
The text was updated successfully, but these errors were encountered: