[gogf/gf]使用jaeger链路追踪报span too large to send

2024-06-25 784 views
0

gf版本是2.1.0-rc3 只在main里添加了 ggg 然后请求一个带有文件上传的接口报这个错了,不过似乎不影响代码的执行:

2022/06/30 16:52:18 span too large to send: Span({TraceIdLow:-1032340765491020852 TraceIdHigh:-9173814157029192106 SpanId:8873447130133058247 ParentSpanId:0 OperationName:/trade/deploy/upload?token=1111&project_id=1542430693110321152 References:[] Flags:1 StartTime:1656579129849630 Duration:8305475 Tags:[Tag({Key:hostname VType:STRING VStr:0xc000c06db0 VDouble: VBool: VLong: VBinary:[]}) Tag({Key:ip.intranet VType:STRING VStr:0xc000c06dc0 VDouble: VBool: VLong: VBinary:[]}) Tag({Key:host.name VType:STRING VStr:0xc000c06dd0 VDouble: VBool: VLong: VBinary:[]}) Tag({Key:otel.library.name VType:STRING VStr:0xc000c06de0 VDouble: VBool: VLong: VBinary:[]}) Tag({Key:otel.library.version VType:STRING VStr:0xc000c06df0 VDouble: VBool: VLong: VBinary:[]}) Tag({Key:span.kind VType:STRING VStr:0xc000c06e00 VDouble: VBool: VLong: VBinary:[]})] Logs:[Log({Timestamp:1656579134821915 Fields:[Tag({Key:event VType:STRING VStr:0xc000c06e10 VDouble: VBool: VLong: VBinary:[]}) Tag({Key:http.request.headers VType:STRING VStr:0xc000c06e20 VDouble: VBool: VLong: VBinary:[]}) Tag({Key:http.request.baggage VType:STRING VStr:0xc000c06e30 VDouble: VBool: VLong: VBinary:[]}) Tag({Key:http.request.body VType:STRING VStr:0xc000c06e40 VDouble: VBool: VLong: VBinary:[]})]}) Log({Timestamp:1656579138155105 Fields:[Tag({Key:event VType:STRING VStr:0xc000c06e50 VDouble: VBool: VLong: VBinary:[]}) Tag({Key:http.response.headers VType:STRING VStr:0xc000c06e60 VDouble: VBool: VLong: VBinary:[]}) Tag({Key:http.response.body VType:STRING VStr:0xc000c06e70 VDouble: VBool: VLong: VBinary:[]})]})]})

回答

9

建议检查是不是把上传的内容上报了,这个内容上报意义不大

9

@houseme jaeger的代码这样写算是全局开启吧?那只要上传文件的接口都会报这个错吗?怎么避免?

3

@houseme jaeger的代码这样写算是全局开启吧?那只要上传文件的接口都会报这个错吗?怎么避免?

发一下你的go.mod 信息

3

@houseme go 1.17

require ( github.com/Azure/go-amqp v0.17.4 github.com/Shopify/sarama v1.30.1 github.com/apache/rocketmq-client-go/v2 v2.1.0 github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 github.com/bufanyun/pool v0.2.1 github.com/bwmarrin/snowflake v0.3.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/disintegration/imaging v1.6.2 github.com/gogf/gf/contrib/drivers/mysql/v2 v2.1.0-rc3 github.com/gogf/gf/contrib/trace/jaeger/v2 v2.1.1 github.com/gogf/gf/v2 v2.1.0-rc3 github.com/gomodule/redigo v2.0.0+incompatible github.com/google/uuid v1.3.0 github.com/influxdata/influxdb-client-go/v2 v2.8.1 github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf github.com/kayon/iploc v0.0.0-20200312105652-bda3e968a794 github.com/klauspost/compress v1.15.1 github.com/mojocn/base64Captcha v1.3.5 github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f github.com/tidwall/gjson v1.2.1 github.com/xuri/excelize/v2 v2.5.0 github.com/zitadel/oidc v1.3.1 go.beyondstorage.io/services/fs/v4 v4.0.0 go.beyondstorage.io/services/minio v0.3.0 go.beyondstorage.io/v5 v5.0.0 go.opentelemetry.io/otel/trace v1.7.0 golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2 )

require ( github.com/BurntSushi/toml v1.1.0 // indirect github.com/Xuanwo/gg v0.2.0 // indirect github.com/Xuanwo/go-bufferpool v0.2.0 // indirect github.com/Xuanwo/templateutils v0.1.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/clbanning/mxj/v2 v2.5.5 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect github.com/dave/dst v0.26.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deepmap/oapi-codegen v1.8.2 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/eapache/go-resiliency v1.2.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect github.com/eapache/queue v1.1.0 // indirect github.com/emirpasic/gods v1.12.0 // indirect github.com/fatih/color v1.13.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/go-logr/logr v1.2.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-redis/redis/v8 v8.11.5 // indirect github.com/go-sql-driver/mysql v1.6.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.0.1 // indirect github.com/gorilla/schema v1.2.0 // indirect github.com/gorilla/securecookie v1.1.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grokify/html-strip-tags-go v0.0.1 // indirect github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect github.com/jcmturner/gofork v1.0.0 // indirect github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect github.com/jcmturner/rpc/v2 v2.0.3 // indirect github.com/json-iterator/go v1.1.10 // indirect github.com/kevinburke/go-bindata v3.22.0+incompatible // indirect github.com/klauspost/cpuid v1.3.1 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect github.com/minio/md5-simd v1.1.0 // indirect github.com/minio/minio-go/v7 v7.0.15 // indirect github.com/minio/sha256-simd v0.1.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pelletier/go-toml v1.9.4 // indirect github.com/pierrec/lz4 v2.6.1+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect github.com/qingstor/go-mime v0.1.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/richardlehane/mscfb v1.0.3 // indirect github.com/richardlehane/msoleps v1.0.1 // indirect github.com/rs/xid v1.2.1 // indirect github.com/russross/blackfriday/v2 v2.0.1 // indirect github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/sirupsen/logrus v1.8.1 // indirect github.com/tidwall/match v1.0.1 // indirect github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65 // indirect github.com/urfave/cli/v2 v2.3.0 // indirect github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3 // indirect go.beyondstorage.io/credential v1.0.0 // indirect go.beyondstorage.io/endpoint v1.2.0 // indirect go.opentelemetry.io/otel v1.7.0 // indirect go.opentelemetry.io/otel/exporters/jaeger v1.7.0 // indirect go.opentelemetry.io/otel/sdk v1.7.0 // indirect go.uber.org/atomic v1.6.0 // indirect golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 // indirect golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb // indirect golang.org/x/mod v0.4.2 // indirect golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect golang.org/x/tools v0.1.7 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/appengine v1.6.6 // indirect google.golang.org/protobuf v1.26.0 // indirect gopkg.in/ini.v1 v1.57.0 // indirect gopkg.in/sourcemap.v1 v1.0.5 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect stathat.com/c/consistent v1.0.0 // indirect )

4

注释一下这一行试试

defer tp.Shutdown(ctx)
5

@houseme 还是一样,只要有上传文件就会报这个错

1

@houseme 还是一样,只要有上传文件就会报这个错

在社群里没有,发一下整个代码吧。

7

@houseme 只能给你发main的代码,程序的代码发不了

var (
    Main = gcmd.Command{
        Name:  "main",
        Usage: "main",
        Brief: "start http server of HotGo!",
        Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {

            if _, err := g.Cfg().Get(ctx, "hotgo.debug"); err != nil {
                g.Log().Fatal(ctx, "配置读取异常:", err, "\r\n你确定 config/config.yaml 文件存在且格式正确吗?\r\n")
            }

            addr, err := g.Cfg().Get(ctx, "jaeger.addr")
            if err != nil {
                g.Log().Fatal(ctx, "配置读取异常:", err, "\r\njaeger配置不正确\r\n")
            }
            serviceName, err := g.Cfg().Get(ctx, "jaeger.service_name")
            if err != nil {
                g.Log().Fatal(ctx, "配置读取异常:", err, "\r\njaeger配置不正确\r\n")
            }
            _, err = jaeger.Init(serviceName.String(), addr.String())
            if err != nil {
                g.Log().Fatal(ctx, err)
            }
            //defer tp.Shutdown(ctx)

            cronVar, err := g.Cfg().Get(ctx, "matomo.cron") //"0 0 */1 * * *" // 一小时执行一次

            if err == nil {
                cronStr := cronVar.String()

                _, err = gcron.Add(ctx, cronStr, func(ctx context.Context) {
                    ctx1 := gctx.New()

                    ctx1, span := gtrace.NewSpan(ctx1, "synchronization")
                    defer span.End()

                    g.Log().Print(ctx1, "浏览量同步定时任务开始")
                    portalService.Market.UpdateProductInfo(ctx1)

                }, "synchronization")

                if err != nil {
                    g.Log().Fatal(ctx, "定时任务启动异常:", err)
                }

            }

            s := g.Server()

            // 错误状态码接管
            s.BindStatusHandler(404, func(r *ghttp.Request) {
                r.Response.Writeln("404 - 你似乎来到了没有知识存在的荒原…")
            })
            s.BindStatusHandler(403, func(r *ghttp.Request) {
                r.Response.Writeln("403 - 网站拒绝显示此网页")
            })

            // 请求结束事件回调
            s.BindHookHandler("/*any", ghttp.HookAfterOutput, hook.Instance().GlobalLog)

            s.Group("/", func(group *ghttp.RouterGroup) {

                // 注册全局中间件
                group.Middleware(
                    middleware.Instance().Ctx, //必须第一个加载
                    middleware.Instance().CORS,
                    middleware.Instance().HandlerResponse,
                )

                // 注册默认首页路由
                group.ALL("/", func(r *ghttp.Request) {
                    r.Response.Write("hello hotGo!!")
                })

                // 注册后台路由
                router.Admin(ctx, group)

                // 注册API路由
                router.Api(ctx, group)

                // 注册编辑器路由
                router.Editor(ctx, group)

                // 注册门户路由
                router.Portal(ctx, group)

                // 注册交易管理路由
                router.Trade(ctx, group)

            })

            // Custom enhance API document.
            enhanceOpenAPIDoc(s)

            // 消息队列
            QueueListen(ctx)

            //阿里云数据监听
            AliyunListen(ctx)

            //定时任务
            enable, err := g.Cfg().Get(ctx, "task.enable")
            if err != nil {
                g.Log().Fatal(ctx, "配置读取异常:", err, "\r\ntask配置不正确\r\n")
            }
            if enable.Bool() {
                StartTask(ctx)
            }
            // Just run the server.
            s.Run()
            return nil
        },
    }
)
3

其他地方没有有关jaeger的代码了

2

解决了吗 我也出现这个问题了