mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
bugfix : when using otel, calling gclient *Raw methods may result in null pointer exceptions (#2697)
This commit is contained in:
@ -73,9 +73,17 @@ func newClientTrace(ctx context.Context, span trace.Span, request *http.Request)
|
||||
func (ct *clientTracer) getConn(host string) {}
|
||||
|
||||
func (ct *clientTracer) gotConn(info httptrace.GotConnInfo) {
|
||||
remoteAddr := ""
|
||||
if info.Conn.RemoteAddr() != nil {
|
||||
remoteAddr = info.Conn.RemoteAddr().String()
|
||||
}
|
||||
localAddr := ""
|
||||
if info.Conn.LocalAddr() != nil {
|
||||
localAddr = info.Conn.LocalAddr().String()
|
||||
}
|
||||
ct.span.SetAttributes(
|
||||
attribute.String(tracingAttrHttpAddressRemote, info.Conn.RemoteAddr().String()),
|
||||
attribute.String(tracingAttrHttpAddressLocal, info.Conn.LocalAddr().String()),
|
||||
attribute.String(tracingAttrHttpAddressRemote, remoteAddr),
|
||||
attribute.String(tracingAttrHttpAddressLocal, localAddr),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user