From 4fe735ce0dbf9b1b64f81fc6911ac300c30f9af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Thu, 9 Sep 2021 10:59:05 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=AE=8C=E5=96=84=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=BC=82=E5=B8=B8=E6=97=B6=E7=9A=84=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/nacos.go | 3 +++ middleware/jaeger.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/nacos.go b/core/nacos.go index 4c4d1ce..9412e1d 100644 --- a/core/nacos.go +++ b/core/nacos.go @@ -49,6 +49,7 @@ func (n nacosClient) Remote(ctx *gin.Context) { }) if err != nil { Log.Error("获取健康服务失败: %v\n", err.Error()) + ctx.String(http.StatusBadGateway, "服务异常: %v", err.Error()) return } // 组装内部接口 @@ -57,6 +58,7 @@ func (n nacosClient) Remote(ctx *gin.Context) { req, err := http.NewRequest(ctx.Request.Method, apiUrl, ctx.Request.Body) if err != nil { Log.Error("请求异常: %v\n", err) + ctx.String(http.StatusBadGateway, "请求异常: %v", err.Error()) return } // 填充Form参数(大概率用不上) @@ -72,6 +74,7 @@ func (n nacosClient) Remote(ctx *gin.Context) { response, err := client.Do(req) if err != nil { Log.Error("请求异常: %v\n", err) + ctx.String(http.StatusBadGateway, "请求异常:%v", err.Error()) return } // 返回结果到前端 diff --git a/middleware/jaeger.go b/middleware/jaeger.go index f35c2b5..b699f7f 100644 --- a/middleware/jaeger.go +++ b/middleware/jaeger.go @@ -66,10 +66,10 @@ func NewJaegerTracer() (opentracing.Tracer, io.Closer) { tracer, closer, err := cfg.NewTracer() if err != nil { - core.Log.Error("Jaeger连接失败: %v", err.Error()) + //core.Log.Error("Jaeger连接失败: %v", err.Error()) return nil, nil } - core.Log.Debug("Jaeger连接成功") + //core.Log.Debug("Jaeger连接成功") opentracing.SetGlobalTracer(tracer) return tracer, closer }