Skip to content

Commit 3fc3bba

Browse files
authored
Block spans (#290)
* feat(impl): add spans to block events * fix(deps): update to go-ipfs-blockstore v1.1.2 * refactor(impl): clean up span naming
1 parent 819100c commit 3fc3bba

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/ipfs/go-datastore v0.5.1
1515
github.com/ipfs/go-ds-badger v0.3.0
1616
github.com/ipfs/go-graphsync v0.11.5
17-
github.com/ipfs/go-ipfs-blockstore v1.1.0
17+
github.com/ipfs/go-ipfs-blockstore v1.1.2
1818
github.com/ipfs/go-ipfs-blocksutil v0.0.1
1919
github.com/ipfs/go-ipfs-chunker v0.0.5
2020
github.com/ipfs/go-ipfs-delay v0.0.1

go.sum

+4-5
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ github.com/ipfs/go-datastore v0.4.0/go.mod h1:SX/xMIKoCszPqp+z9JhPYCmoOoXTvaa13X
389389
github.com/ipfs/go-datastore v0.4.1/go.mod h1:SX/xMIKoCszPqp+z9JhPYCmoOoXTvaa13XEbGtsFUhA=
390390
github.com/ipfs/go-datastore v0.4.4/go.mod h1:SX/xMIKoCszPqp+z9JhPYCmoOoXTvaa13XEbGtsFUhA=
391391
github.com/ipfs/go-datastore v0.4.5/go.mod h1:eXTcaaiN6uOlVCLS9GjJUJtlvJfM3xk23w3fyfrmmJs=
392-
github.com/ipfs/go-datastore v0.4.7-0.20211013204805-28a3721c2e66/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk=
393392
github.com/ipfs/go-datastore v0.5.0/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk=
394393
github.com/ipfs/go-datastore v0.5.1 h1:WkRhLuISI+XPD0uk3OskB0fYFSyqK8Ob5ZYew9Qa1nQ=
395394
github.com/ipfs/go-datastore v0.5.1/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk=
@@ -409,8 +408,8 @@ github.com/ipfs/go-graphsync v0.11.5 h1:WA5hVxGBtcal6L6nqubKiqRolaZxbexOK3GumGFJ
409408
github.com/ipfs/go-graphsync v0.11.5/go.mod h1:+/sZqRwRCQRrV7NCzgBtufmr5QGpUE98XSa7NlsztmM=
410409
github.com/ipfs/go-ipfs-blockstore v0.0.1/go.mod h1:d3WClOmRQKFnJ0Jz/jj/zmksX0ma1gROTlovZKBmN08=
411410
github.com/ipfs/go-ipfs-blockstore v0.2.1/go.mod h1:jGesd8EtCM3/zPgx+qr0/feTXGUeRai6adgwC+Q+JvE=
412-
github.com/ipfs/go-ipfs-blockstore v1.1.0 h1:ZIZ2qgHO5pftHW0oHTfx+LoO+Me2xHkVAexhVpgGL3I=
413-
github.com/ipfs/go-ipfs-blockstore v1.1.0/go.mod h1:5QDUApRqpgPcfGstCxYeMnjt/DYQtXXdJVCvxHHuWVk=
411+
github.com/ipfs/go-ipfs-blockstore v1.1.2 h1:WCXoZcMYnvOTmlpX+RSSnhVN0uCmbWTeepTGX5lgiXw=
412+
github.com/ipfs/go-ipfs-blockstore v1.1.2/go.mod h1:w51tNR9y5+QXB0wkNcHt4O2aSZjTdqaEWaQdSxEyUOY=
414413
github.com/ipfs/go-ipfs-blocksutil v0.0.1 h1:Eh/H4pc1hsvhzsQoMEP3Bke/aW5P5rVM1IWFJMcGIPQ=
415414
github.com/ipfs/go-ipfs-blocksutil v0.0.1/go.mod h1:Yq4M86uIOmxmGPUHv/uI7uKqZNtLb449gwKqXjIsnRk=
416415
github.com/ipfs/go-ipfs-chunker v0.0.1/go.mod h1:tWewYK0we3+rMbOh7pPFGDyypCtvGcBFymgY4rSDLAw=
@@ -421,8 +420,8 @@ github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1I
421420
github.com/ipfs/go-ipfs-delay v0.0.1/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
422421
github.com/ipfs/go-ipfs-ds-help v0.0.1/go.mod h1:gtP9xRaZXqIQRh1HRpp595KbBEdgqWFxefeVKOV8sxo=
423422
github.com/ipfs/go-ipfs-ds-help v0.1.1/go.mod h1:SbBafGJuGsPI/QL3j9Fc5YPLeAu+SzOkI0gFwAg+mOs=
424-
github.com/ipfs/go-ipfs-ds-help v1.0.0 h1:bEQ8hMGs80h0sR8O4tfDgV6B01aaF9qeTrujrTLYV3g=
425-
github.com/ipfs/go-ipfs-ds-help v1.0.0/go.mod h1:ujAbkeIgkKAWtxxNkoZHWLCyk5JpPoKnGyCcsoF6ueE=
423+
github.com/ipfs/go-ipfs-ds-help v1.1.0 h1:yLE2w9RAsl31LtfMt91tRZcrx+e61O5mDxFRR994w4Q=
424+
github.com/ipfs/go-ipfs-ds-help v1.1.0/go.mod h1:YR5+6EaebOhfcqVCyqemItCLthrpVNot+rsOU/5IatU=
426425
github.com/ipfs/go-ipfs-exchange-interface v0.0.1/go.mod h1:c8MwfHjtQjPoDyiy9cFquVtVHkO9b9Ob3FG91qJnWCM=
427426
github.com/ipfs/go-ipfs-exchange-interface v0.1.0 h1:TiMekCrOGQuWYtZO3mf4YJXDIdNgnKWZ9IE3fGlnWfo=
428427
github.com/ipfs/go-ipfs-exchange-interface v0.1.0/go.mod h1:ych7WPlyHqFvCi/uQI48zLZuAWVP5iTQPXEfVaw5WEI=

impl/events.go

+30
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import (
88
"github.com/ipld/go-ipld-prime"
99
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
1010
"github.com/libp2p/go-libp2p-core/peer"
11+
"go.opentelemetry.io/otel"
12+
"go.opentelemetry.io/otel/attribute"
13+
"go.opentelemetry.io/otel/trace"
1114
"golang.org/x/xerrors"
1215

1316
datatransfer "github.com/filecoin-project/go-data-transfer"
@@ -39,6 +42,15 @@ func (m *manager) OnChannelOpened(chid datatransfer.ChannelID) error {
3942
// calls revalidators so they can pause / resume the channel or send a
4043
// message over the transport.
4144
func (m *manager) OnDataReceived(chid datatransfer.ChannelID, link ipld.Link, size uint64, index int64) error {
45+
ctx, _ := m.spansIndex.SpanForChannel(context.TODO(), chid)
46+
ctx, span := otel.Tracer("data-transfer").Start(ctx, "dataReceived", trace.WithAttributes(
47+
attribute.String("channelID", chid.String()),
48+
attribute.String("link", link.String()),
49+
attribute.Int64("index", index),
50+
attribute.Int64("size", int64(size)),
51+
))
52+
defer span.End()
53+
4254
isNew, err := m.channels.DataReceived(chid, link.(cidlink.Link).Cid, size, index)
4355
if err != nil {
4456
return err
@@ -89,6 +101,15 @@ func (m *manager) OnDataQueued(chid datatransfer.ChannelID, link ipld.Link, size
89101
// The transport layer reports that some data has been queued up to be sent
90102
// to the requester, so fire a DataQueued event on the channels state
91103
// machine.
104+
105+
ctx, _ := m.spansIndex.SpanForChannel(context.TODO(), chid)
106+
ctx, span := otel.Tracer("data-transfer").Start(ctx, "dataQueued", trace.WithAttributes(
107+
attribute.String("channelID", chid.String()),
108+
attribute.String("link", link.String()),
109+
attribute.Int64("size", int64(size)),
110+
))
111+
defer span.End()
112+
92113
isNew, err := m.channels.DataQueued(chid, link.(cidlink.Link).Cid, size)
93114
if err != nil {
94115
return nil, err
@@ -127,6 +148,15 @@ func (m *manager) OnDataQueued(chid datatransfer.ChannelID, link ipld.Link, size
127148
}
128149

129150
func (m *manager) OnDataSent(chid datatransfer.ChannelID, link ipld.Link, size uint64) error {
151+
152+
ctx, _ := m.spansIndex.SpanForChannel(context.TODO(), chid)
153+
ctx, span := otel.Tracer("data-transfer").Start(ctx, "dataSent", trace.WithAttributes(
154+
attribute.String("channelID", chid.String()),
155+
attribute.String("link", link.String()),
156+
attribute.Int64("size", int64(size)),
157+
))
158+
defer span.End()
159+
130160
_, err := m.channels.DataSent(chid, link.(cidlink.Link).Cid, size)
131161
return err
132162
}

0 commit comments

Comments
 (0)