…/…/…/…/gowork/pkg/mod/github.com/gogf/gf@v1.16.6/net/ghttp/internal/client/client_tracing.go:73:3: undefined: attribute.Any
…/…/…/…/gowork/pkg/mod/github.com/gogf/gf@v1.16.6/net/ghttp/internal/client/client_tracing_tracer.go:150:3: undefined: attribute.Any
…/…/…/…/gowork/pkg/mod/github.com/gogf/gf@v1.16.6/net/ghttp/internal/client/client_tracing_tracer.go:151:3: undefined: attribute.Any
用GoFrame1.16.6 和Kratos2.1.2开发,都依赖了 go.opentelemetry.io/otel
Kratos写好的打成包,在Goframe里面引用,然后就出错了。
Kratos 引用的是otel v1.2.0
GoFrame 引用的是 v1.0.0-RC2
使用 go mod tidy 的时候会使用 v1.2.0 而 v1.2.0版本没有attribute.Any方法
尝试将 Kratos 的依赖降级为 v1.0.0-RC2 不行,就是要 v1.2.0
解决:在go.mod 里面使用replace语法
Goframe:
replace go.opentelemetry.io/otel => go.opentelemetry.io/otel v1.0.0-RC2
replace go.opentelemetry.io/otel/trace => go.opentelemetry.io/otel/trace v1.0.0-RC2
Kratos:
replace go.opentelemetry.io/otel => go.opentelemetry.io/otel v1.2.0
replace go.opentelemetry.io/otel/trace => go.opentelemetry.io/otel/trace v1.2.0
replace go.opentelemetry.io/otel/exporters/jaeger => go.opentelemetry.io/otel/exporters/jaeger v1.2.0
require 为各自所需依赖的版本号(可能没有)
排查
go get github.com/gogf/gf-tracing
错误:
go get: github.com/gogf/gf-tracing@v0.0.0-20211121144254-0ec23be54000 requires
github.com/gogf/katyusha@v0.1.3-0.20210402080039-f9c0f380474e requires
go.etcd.io/etcd/api/v3@v3.5.0-pre: reading https://goproxy.cn/go.etcd.io/etcd/api/v3/@v/v3.5.0-pre.mod: 404 Not Found
server response: not found: go.etcd.io/etcd/api/v3@v3.5.0-pre: invalid version: unknown revision api/v3.5.0-pre
用go mod why “包名” 排查
usage: go mod why [-m] [-vendor] packages...
Why shows a shortest path in the import graph from the main module to
each of the listed packages. If the -m flag is given, why treats the
arguments as a list of modules and finds a path to any package in each
of the modules.
By default, why queries the graph of packages matched by "go list all",
which includes tests for reachable packages. The -vendor flag causes why
to exclude tests of dependencies.
The output is a sequence of stanzas, one for each package or module
name on the command line, separated by blank lines. Each stanza begins
with a comment line "# package" or "# module" giving the target
package or module. Subsequent lines give a path through the import
graph, one package per line. If the package or module is not
referenced from the main module, the stanza will display a single
parenthesized note indicating that fact.
For example:
$ go mod why golang.org/x/text/language golang.org/x/text/encoding
# golang.org/x/text/language
rsc.io/quote
rsc.io/sampler
golang.org/x/text/language
# golang.org/x/text/encoding
(main module does not need package golang.org/x/text/encoding)
$
See https://golang.org/ref/mod#go-mod-why for more about 'go mod why'.
使用 https://pkg.go.dev/ 查询包版本
例如 :
tracing package - github.com/gogf/gf-tracing/tracing - pkg.go.dev
https://pkg.go.dev/github.com/gogf/gf-tracing/tracing
查看go.mod
继续找包
github.com/gogf/katyusha 依赖
这里用到是 go.etcd.io/etcd/api/v3@v3.5.0 不是自动下载的go.etcd.io/etcd/api/v3@v3.5.0-pre 迷惑
找本地的源文件,发现没有。。。。 执行go get github.com/gogf/katyusha 下载下来的是v0.2.0
而报错的是github.com/gogf/katyusha@v0.1.3-0.20210402080039-f9c0f380474e