优化jaeger代码,使用otlp规范

This commit is contained in:
2025-11-26 10:38:15 +08:00
parent cf65e0383c
commit 15a5311288
2 changed files with 17 additions and 35 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
_ "gitee.com/red-future---jilin-g/common/consul"
"gitee.com/red-future---jilin-g/common/jaeger"
"gitee.com/red-future---jilin-g/common/utils"
"github.com/gogf/gf/contrib/registry/consul/v2"
@@ -31,16 +32,16 @@ type Page struct {
Total int //总页数
}
var HttpServer = g.Server()
var Httpserver = g.Server()
func init() {
//s.Use(common.Cors) //中间件验证
//s.EnablePProf() //启用性能分析
HttpServer.SetOpenApiPath("/api.json")
HttpServer.SetSwaggerPath("/swagger") //api文档访问路径
HttpServer.SetDumpRouterMap(true) //关闭打印路由注册信息
HttpServer.BindMiddlewareDefault(ghttp.MiddlewareHandlerResponse, jaeger.NewTracer) //使用默认http返回结构
go HttpServer.Run()
Httpserver.SetOpenApiPath("/api.json")
Httpserver.SetSwaggerPath("/swagger") //api文档访问路径
Httpserver.SetDumpRouterMap(true) //关闭打印路由注册信息
Httpserver.BindMiddlewareDefault(ghttp.MiddlewareHandlerResponse, jaeger.NewTracer) //使用默认http返回结构
go Httpserver.Run()
}
func RouteRegister(controllers []interface{}) {
re := regexp.MustCompile("[A-Z]")
@@ -49,7 +50,7 @@ func RouteRegister(controllers []interface{}) {
convertedStr := re.ReplaceAllStringFunc(sName, func(s string) string {
return fmt.Sprintf("/%s", strings.ToLower(s))
})
HttpServer.Group(convertedStr, func(group *ghttp.RouterGroup) {
Httpserver.Group(convertedStr, func(group *ghttp.RouterGroup) {
group.Bind(t)
})
}