Skip to content

Commit 1b3e443

Browse files
authored
chore: upgrade OpenTelemetry dependencies (#9736)
1 parent fd830b3 commit 1b3e443

17 files changed

+164
-109
lines changed

.github/workflows/build.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
runs-on: ubuntu-latest
2121
timeout-minutes: 5
2222
env:
23-
TEST_NO_DOCKER: 1
24-
TEST_NO_FUSE: 1
23+
TEST_DOCKER: 0
24+
TEST_FUSE: 0
2525
TEST_VERBOSE: 1
2626
TRAVIS: 1
2727
GIT_PAGER: cat
@@ -86,8 +86,8 @@ jobs:
8686
runs-on: ubuntu-latest
8787
timeout-minutes: 5
8888
env:
89-
TEST_NO_DOCKER: 1
90-
TEST_NO_FUSE: 1
89+
TEST_DOCKER: 0
90+
TEST_FUSE: 0
9191
TEST_VERBOSE: 1
9292
TRAVIS: 1
9393
GIT_PAGER: cat
@@ -126,8 +126,8 @@ jobs:
126126
runs-on: ubuntu-latest
127127
timeout-minutes: 5
128128
env:
129-
TEST_NO_DOCKER: 1
130-
TEST_NO_FUSE: 1
129+
TEST_DOCKER: 0
130+
TEST_FUSE: 0
131131
TEST_VERBOSE: 1
132132
TRAVIS: 1
133133
GIT_PAGER: cat

.github/workflows/gobuild.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ${{ fromJSON(needs.go-build-runner.outputs.config).labels }}
2121
timeout-minutes: 20
2222
env:
23-
TEST_NO_DOCKER: 1
23+
TEST_DOCKER: 0
2424
TEST_VERBOSE: 1
2525
TRAVIS: 1
2626
GIT_PAGER: cat
@@ -38,7 +38,7 @@ jobs:
3838
name: ${{ github.job }}
3939
- run: make cmd/ipfs-try-build
4040
env:
41-
TEST_NO_FUSE: 0
41+
TEST_FUSE: 1
4242
- run: make cmd/ipfs-try-build
4343
env:
44-
TEST_NO_FUSE: 1
44+
TEST_FUSE: 0

.github/workflows/golint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
runs-on: ubuntu-latest
1818
timeout-minutes: 10
1919
env:
20-
TEST_NO_DOCKER: 1
21-
TEST_NO_FUSE: 1
20+
TEST_DOCKER: 0
21+
TEST_FUSE: 0
2222
TEST_VERBOSE: 1
2323
TRAVIS: 1
2424
GIT_PAGER: cat

.github/workflows/gotest.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ jobs:
2020
runs-on: ${{ fromJSON(needs.go-test-runner.outputs.config).labels }}
2121
timeout-minutes: 20
2222
env:
23-
TEST_NO_DOCKER: 1
24-
TEST_NO_FUSE: 1
23+
TEST_DOCKER: 0
24+
TEST_FUSE: 0
2525
TEST_VERBOSE: 1
2626
TRAVIS: 1
2727
GIT_PAGER: cat

.github/workflows/sharness.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ jobs:
4949
test/sharness/test-results/sharness.xml
5050
working-directory: kubo
5151
env:
52-
TEST_NO_DOCKER: 0
53-
TEST_NO_PLUGIN: 1
54-
TEST_NO_FUSE: 1
52+
TEST_DOCKER: 1
53+
TEST_PLUGIN: 0
54+
TEST_FUSE: 0
5555
TEST_VERBOSE: 1
5656
TEST_JUNIT: 1
5757
TEST_EXPENSIVE: 1

Rules.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ include mk/golang.mk
1919
# extra properties #
2020
# -------------------- #
2121

22-
ifeq ($(TEST_NO_FUSE),1)
22+
ifeq ($(TEST_FUSE),0)
2323
GOTAGS += nofuse
2424
endif
2525
export LIBP2P_TCP_REUSEPORT=false

coverage/Rules.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ endif
4545

4646
export IPFS_COVER_DIR:= $(realpath $(d))/sharnesscover/
4747

48-
$(d)/sharness_tests.coverprofile: export TEST_NO_PLUGIN=1
48+
$(d)/sharness_tests.coverprofile: export TEST_PLUGIN=0
4949
$(d)/sharness_tests.coverprofile: $(d)/ipfs cmd/ipfs/ipfs-test-cover $(d)/coverage_deps test_sharness
5050
(cd $(@D)/sharnesscover && find . -type f | gocovmerge -list -) > $@
5151

go.mod

+6-6
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,15 @@ require (
7272
github.com/whyrusleeping/go-sysinfo v0.0.0-20190219211824-4a357d4b90b1
7373
github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7
7474
go.opencensus.io v0.24.0
75-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0
75+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0
7676
go.opentelemetry.io/otel v1.14.0
7777
go.opentelemetry.io/otel/exporters/jaeger v1.14.0
78-
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect
79-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 // indirect
8078
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0
8179
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0
8280
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0
8381
go.opentelemetry.io/otel/exporters/zipkin v1.14.0
8482
go.opentelemetry.io/otel/sdk v1.14.0
8583
go.opentelemetry.io/otel/trace v1.14.0
86-
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
8784
go.uber.org/dig v1.15.0
8885
go.uber.org/fx v1.18.2
8986
go.uber.org/zap v1.24.0
@@ -113,7 +110,7 @@ require (
113110
github.com/docker/go-units v0.5.0 // indirect
114111
github.com/elastic/gosigar v0.14.2 // indirect
115112
github.com/emirpasic/gods v1.18.1 // indirect
116-
github.com/felixge/httpsnoop v1.0.2 // indirect
113+
github.com/felixge/httpsnoop v1.0.3 // indirect
117114
github.com/flynn/noise v1.0.0 // indirect
118115
github.com/francoispqt/gojay v1.2.13 // indirect
119116
github.com/gabriel-vasile/mimetype v1.4.1 // indirect
@@ -208,7 +205,10 @@ require (
208205
github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa // indirect
209206
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect
210207
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
211-
go.opentelemetry.io/otel/metric v0.30.0 // indirect
208+
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect
209+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 // indirect
210+
go.opentelemetry.io/otel/metric v0.37.0 // indirect
211+
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
212212
go.uber.org/atomic v1.10.0 // indirect
213213
go.uber.org/multierr v1.9.0 // indirect
214214
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect

go.sum

+6-9
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 h1:BBso6MBKW
170170
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5/go.mod h1:JpoxHjuQauoxiFMl1ie8Xc/7TfLuMZ5eOCONd1sUBHg=
171171
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
172172
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
173-
github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o=
174-
github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
173+
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
174+
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
175175
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
176176
github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ=
177177
github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag=
@@ -291,7 +291,6 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
291291
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
292292
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
293293
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
294-
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
295294
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
296295
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
297296
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
@@ -922,9 +921,8 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
922921
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
923922
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
924923
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
925-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0 h1:mac9BKRqwaX6zxHPDe3pvmWpwuuIM0vuXv2juCnQevE=
926-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0/go.mod h1:5eCOqeGphOyz6TsY3ZDNjE33SM/TFAK3RGuCL2naTgY=
927-
go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk=
924+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0 h1:lE9EJyw3/JhrjWH/hEy9FptnalDQgj7vpbgC2KCCCxE=
925+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0/go.mod h1:pcQ3MM3SWvrA71U4GDqv9UFDJ3HQsW7y5ZO3tDTlUdI=
928926
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
929927
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
930928
go.opentelemetry.io/otel/exporters/jaeger v1.14.0 h1:CjbUNd4iN2hHmWekmOqZ+zSCU+dzZppG8XsV+A3oc8Q=
@@ -941,11 +939,10 @@ go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 h1:sEL90JjOO/4yhqu
941939
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0/go.mod h1:oCslUcizYdpKYyS9e8srZEqM6BB8fq41VJBjLAE6z1w=
942940
go.opentelemetry.io/otel/exporters/zipkin v1.14.0 h1:reEVE1upBF9tcujgvSqLJS0SrI7JQPaTKP4s4rymnSs=
943941
go.opentelemetry.io/otel/exporters/zipkin v1.14.0/go.mod h1:RcjvOAcvhzcufQP8aHmzRw1gE9g/VEZufDdo2w+s4sk=
944-
go.opentelemetry.io/otel/metric v0.30.0 h1:Hs8eQZ8aQgs0U49diZoaS6Uaxw3+bBE3lcMUKBFIk3c=
945-
go.opentelemetry.io/otel/metric v0.30.0/go.mod h1:/ShZ7+TS4dHzDFmfi1kSXMhMVubNoP0oIaBp70J6UXU=
942+
go.opentelemetry.io/otel/metric v0.37.0 h1:pHDQuLQOZwYD+Km0eb657A25NaRzy0a+eLyKfDXedEs=
943+
go.opentelemetry.io/otel/metric v0.37.0/go.mod h1:DmdaHfGt54iV6UKxsV9slj2bBRJcKC1B1uvDLIioc1s=
946944
go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY=
947945
go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM=
948-
go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU=
949946
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
950947
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
951948
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=

test/cli/harness/node.go

+23-7
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,29 @@ func (n *Node) Init(ipfsArgs ...string) *Node {
211211
return n
212212
}
213213

214-
func (n *Node) StartDaemon(ipfsArgs ...string) *Node {
214+
// StartDaemonWithReq runs a Kubo daemon with the given request.
215+
// This overwrites the request Path with the Kubo bin path.
216+
//
217+
// For example, if you want to run the daemon and see stderr and stdout to debug:
218+
//
219+
// node.StartDaemonWithReq(harness.RunRequest{
220+
// CmdOpts: []harness.CmdOpt{
221+
// harness.RunWithStderr(os.Stdout),
222+
// harness.RunWithStdout(os.Stdout),
223+
// },
224+
// })
225+
func (n *Node) StartDaemonWithReq(req RunRequest) *Node {
215226
alive := n.IsAlive()
216227
if alive {
217228
log.Panicf("node %d is already running", n.ID)
218229
}
230+
newReq := req
231+
newReq.Path = n.IPFSBin
232+
newReq.Args = append([]string{"daemon"}, req.Args...)
233+
newReq.RunFunc = (*exec.Cmd).Start
219234

220-
daemonArgs := append([]string{"daemon"}, ipfsArgs...)
221235
log.Debugf("starting node %d", n.ID)
222-
res := n.Runner.MustRun(RunRequest{
223-
Path: n.IPFSBin,
224-
Args: daemonArgs,
225-
RunFunc: (*exec.Cmd).Start,
226-
})
236+
res := n.Runner.MustRun(newReq)
227237

228238
n.Daemon = res
229239

@@ -232,6 +242,12 @@ func (n *Node) StartDaemon(ipfsArgs ...string) *Node {
232242
return n
233243
}
234244

245+
func (n *Node) StartDaemon(ipfsArgs ...string) *Node {
246+
return n.StartDaemonWithReq(RunRequest{
247+
Args: ipfsArgs,
248+
})
249+
}
250+
235251
func (n *Node) signalAndWait(watch <-chan struct{}, signal os.Signal, t time.Duration) bool {
236252
err := n.Daemon.Cmd.Process.Signal(signal)
237253
if err != nil {

test/cli/harness/run.go

+12
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,15 @@ func RunWithStdin(reader io.Reader) CmdOpt {
142142
func RunWithStdinStr(s string) CmdOpt {
143143
return RunWithStdin(strings.NewReader(s))
144144
}
145+
146+
func RunWithStdout(writer io.Writer) CmdOpt {
147+
return func(cmd *exec.Cmd) {
148+
cmd.Stdout = io.MultiWriter(writer, cmd.Stdout)
149+
}
150+
}
151+
152+
func RunWithStderr(writer io.Writer) CmdOpt {
153+
return func(cmd *exec.Cmd) {
154+
cmd.Stderr = io.MultiWriter(writer, cmd.Stdout)
155+
}
156+
}

test/cli/testutils/requires.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import (
77
)
88

99
func RequiresDocker(t *testing.T) {
10-
if os.Getenv("TEST_NO_DOCKER") == "1" {
10+
if os.Getenv("TEST_DOCKER") != "1" {
1111
t.SkipNow()
1212
}
1313
}
1414

1515
func RequiresFUSE(t *testing.T) {
16-
if os.Getenv("TEST_NO_FUSE") == "1" {
16+
if os.Getenv("TEST_FUSE") != "1" {
1717
t.SkipNow()
1818
}
1919
}
@@ -25,7 +25,7 @@ func RequiresExpensive(t *testing.T) {
2525
}
2626

2727
func RequiresPlugins(t *testing.T) {
28-
if os.Getenv("TEST_NO_PLUGIN") == "1" {
28+
if os.Getenv("TEST_PLUGIN") != "1" {
2929
t.SkipNow()
3030
}
3131
}

test/cli/tracing_test.go

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package cli
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"os/exec"
7+
"path/filepath"
8+
"strings"
9+
"testing"
10+
"time"
11+
12+
"github.com/ipfs/kubo/test/cli/harness"
13+
"github.com/ipfs/kubo/test/cli/testutils"
14+
"github.com/stretchr/testify/assert"
15+
"github.com/stretchr/testify/require"
16+
)
17+
18+
var otelCollectorConfigYAML = `
19+
receivers:
20+
otlp:
21+
protocols:
22+
grpc:
23+
24+
processors:
25+
batch:
26+
27+
exporters:
28+
file:
29+
path: /traces/traces.json
30+
31+
service:
32+
pipelines:
33+
traces:
34+
receivers: [otlp]
35+
processors: [batch]
36+
exporters: [file]
37+
`
38+
39+
func TestTracing(t *testing.T) {
40+
testutils.RequiresDocker(t)
41+
t.Parallel()
42+
node := harness.NewT(t).NewNode().Init()
43+
44+
node.WriteBytes("collector-config.yaml", []byte(otelCollectorConfigYAML))
45+
46+
// touch traces.json and give it 777 perms in case Docker runs as a different user
47+
node.WriteBytes("traces.json", nil)
48+
err := os.Chmod(filepath.Join(node.Dir, "traces.json"), 0777)
49+
require.NoError(t, err)
50+
51+
dockerBin, err := exec.LookPath("docker")
52+
require.NoError(t, err)
53+
node.Runner.MustRun(harness.RunRequest{
54+
Path: dockerBin,
55+
Args: []string{
56+
"run",
57+
"--rm",
58+
"--detach",
59+
"--volume", fmt.Sprintf("%s:/config.yaml", filepath.Join(node.Dir, "collector-config.yaml")),
60+
"--volume", fmt.Sprintf("%s:/traces", node.Dir),
61+
"--net", "host",
62+
"--name", "ipfs-test-otel-collector",
63+
"otel/opentelemetry-collector-contrib:0.52.0",
64+
"--config", "/config.yaml",
65+
},
66+
})
67+
68+
t.Cleanup(func() {
69+
node.Runner.MustRun(harness.RunRequest{
70+
Path: dockerBin,
71+
Args: []string{"stop", "ipfs-test-otel-collector"},
72+
})
73+
})
74+
75+
node.Runner.Env["OTEL_TRACES_EXPORTER"] = "otlp"
76+
node.Runner.Env["OTEL_EXPORTER_OTLP_PROTOCOL"] = "grpc"
77+
node.Runner.Env["OTEL_EXPORTER_OTLP_ENDPOINT"] = "http://localhost:4317"
78+
node.StartDaemon()
79+
80+
assert.Eventually(t,
81+
func() bool {
82+
b, err := os.ReadFile(filepath.Join(node.Dir, "traces.json"))
83+
require.NoError(t, err)
84+
return strings.Contains(string(b), "go-ipfs")
85+
},
86+
5*time.Minute,
87+
10*time.Millisecond,
88+
)
89+
}

test/sharness/Rules.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $(PLUGINS_$(d)): $(ORGIN_PLUGINS_$(d))
2121
@mkdir -p $(@D)
2222
cp -f plugin/plugins/$(@F) $@
2323

24-
ifneq ($(TEST_NO_PLUGIN),1)
24+
ifneq ($(TEST_PLUGIN),0)
2525
DEPS_$(d) += $(PLUGINS_$(d))
2626
endif
2727
endif

0 commit comments

Comments
 (0)