Skip to content

Commit 368618e

Browse files
authored
Merge pull request #135 from gfanton/feat/add-eventbus-metrics
2 parents 5288b5d + 7ab1b80 commit 368618e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

accesscontroller/orbitdb/accesscontroller_orbitdb.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
cid "github.com/ipfs/go-cid"
1818
"github.com/libp2p/go-libp2p/core/event"
19+
"github.com/libp2p/go-libp2p/p2p/host/eventbus"
1920
"go.uber.org/zap"
2021
)
2122

@@ -217,7 +218,7 @@ func (o *orbitDBAccessController) Load(ctx context.Context, address string) erro
217218
new(stores.EventWrite),
218219
new(stores.EventReady),
219220
new(stores.EventReplicated),
220-
})
221+
}, eventbus.Name("odb/load"))
221222
if err != nil {
222223
return fmt.Errorf("unable subscribe to store events: %w", err)
223224
}

baseorbitdb/orbitdb.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,8 @@ func (o *orbitDB) EventBus() event.Bus {
813813
}
814814

815815
func (o *orbitDB) monitorDirectChannel(ctx context.Context, bus event.Bus) error {
816-
sub, err := bus.Subscribe(new(iface.EventPubSubPayload), eventbus.BufSize(128))
816+
sub, err := bus.Subscribe(new(iface.EventPubSubPayload),
817+
eventbus.BufSize(128), eventbus.Name("odb/monitor-direct-channel"))
817818
if err != nil {
818819
return fmt.Errorf("unable to init pubsub subscriber: %w", err)
819820
}

stores/basestore/base_store.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ func (b *BaseStore) InitBaseStore(ipfs coreapi.CoreAPI, identity *identityprovid
268268

269269
b.options = options
270270

271-
sub, err := b.replicator.EventBus().Subscribe(replicator.Events, eventbus.BufSize(128))
271+
sub, err := b.replicator.EventBus().Subscribe(replicator.Events,
272+
eventbus.BufSize(128), eventbus.Name("odb/base-store-main-loop"))
272273
if err != nil {
273274
return fmt.Errorf("unable to subscribe to replicator events: %w", err)
274275
}
@@ -1008,7 +1009,7 @@ func (b *BaseStore) replicate() error {
10081009
}
10091010

10101011
func (b *BaseStore) storeListener(topic iface.PubSubTopic) error {
1011-
sub, err := b.EventBus().Subscribe(new(stores.EventWrite))
1012+
sub, err := b.EventBus().Subscribe(new(stores.EventWrite), eventbus.Name("odb/store-listener"))
10121013
if err != nil {
10131014
return fmt.Errorf("unable to init event bus: %w", err)
10141015
}

0 commit comments

Comments
 (0)