This commit is contained in:
parent
cd2530afa4
commit
21950f5dbf
@ -39,7 +39,7 @@ func initNacos() {
|
||||
if ips := utils.GetIps(); ips != nil {
|
||||
ip = ips[0]
|
||||
}
|
||||
success, _ := client.RegisterInstance(vo.RegisterInstanceParam{
|
||||
success, err := client.RegisterInstance(vo.RegisterInstanceParam{
|
||||
Ip: ip,
|
||||
Port: config.AppInfo.Port,
|
||||
Weight: 10,
|
||||
@ -50,7 +50,7 @@ func initNacos() {
|
||||
})
|
||||
core.Log.Debug("Nacos注册结果: %v", success)
|
||||
if !success {
|
||||
core.Log.Panic("服务注册失败,退出程序")
|
||||
core.Log.Panic("服务注册失败,退出程序: %v", err.Error())
|
||||
}
|
||||
|
||||
// 打印所有服务
|
||||
|
@ -3,6 +3,7 @@ package middleware
|
||||
import (
|
||||
"fmt"
|
||||
gc "gateway/config"
|
||||
"gateway/core"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
"github.com/opentracing/opentracing-go/ext"
|
||||
@ -20,6 +21,7 @@ func OpenTracing() gin.HandlerFunc {
|
||||
spCtx, err := opentracing.GlobalTracer().Extract(opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(c.Request.Header))
|
||||
|
||||
if err != nil {
|
||||
core.Log.Error("Jaeger错误: %v", err.Error())
|
||||
parentSpan = tracer.StartSpan(c.Request.URL.Path)
|
||||
defer parentSpan.Finish()
|
||||
} else {
|
||||
@ -47,8 +49,6 @@ func OpenTracing() gin.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
//var Tracer opentracing.Tracer
|
||||
|
||||
func NewJaegerTracer() (opentracing.Tracer, io.Closer) {
|
||||
cfg := &config.Configuration{
|
||||
Sampler: &config.SamplerConfig{
|
||||
@ -66,9 +66,10 @@ func NewJaegerTracer() (opentracing.Tracer, io.Closer) {
|
||||
|
||||
tracer, closer, err := cfg.NewTracer()
|
||||
if err != nil {
|
||||
core.Log.Error("Jaeger连接失败: %v", err.Error())
|
||||
return nil, nil
|
||||
}
|
||||
core.Log.Debug("Jaeger连接成功")
|
||||
opentracing.SetGlobalTracer(tracer)
|
||||
//Tracer = tracer
|
||||
return tracer, closer
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
@ -17,11 +16,10 @@ func GetIps() []string {
|
||||
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet.IP.To4() != nil {
|
||||
ip := ipnet.IP.String()
|
||||
fmt.Println(ip)
|
||||
ips = append(ips, ip)
|
||||
}
|
||||
}
|
||||
}
|
||||
//ipStr := strings.Join(aaaa, ",")
|
||||
//ipStr := strings.Join(ips, ",")
|
||||
return ips
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user