libp2p / js-libp2p

The JavaScript Implementation of libp2p networking stack.
https://libp2p.io
Other
2.27k stars 436 forks source link

feat: add devtools metrics #2551

Closed achingbrain closed 1 month ago

achingbrain commented 1 month ago

Adds a metrics implementation that is scrapable by a browser DevTools plugin.

Change checklist

2color commented 1 month ago

Sweet!

When trying this out using the following libp2p config, I get the following error:

TypeError: Cannot read properties of undefined (reading 'update')
    at TrackedMap.updateComponentMetric (tracked-map.ts:38:17)
    at new TrackedMap (tracked-map.ts:17:10)
    at trackedMap (tracked-map.ts:59:11)
    at new DefaultTransportManager (transport-manager.ts:33:22)
    at new Libp2pNode (libp2p.ts:118:49)
    at createLibp2pNode (libp2p.ts:418:10)
    at async createLibp2p (index.ts:167:16)
    at async App (index.js:50:18)

Do you know what might be the reason?

achingbrain commented 1 month ago

Do you know what might be the reason?

I think you may be using the placeholder version published to npm. You'll need to replace the src and dist folders in /node_modules/libp2p/devtools-metrics with versions built from this PR branch for it to work.