go-algorand
go-algorand copied to clipboard
p2p: add telemetry and DHT/libp2p metrics
Summary
Add missing p2p telemetry similarly to wsNetwork:
- [x] meshThread peers connection stats - generalize and reuse
sendPeerConnectionsTelemetryStatus
from wsNet - [x] ConnectedIn / ConnectedOut
- [x] Disconnect
In order to propagate telemetryID and instanceName provided by logging module, p2p peers expose a fake /algorand-telemetry/1.0.0/{TID}/{INSTANCE}
protocol so that remote side can discover it and treat as some extra meta information. This is a workaround for HTTP transport with its custom HTTP headers.
Add DHT stats collected with OpenCensus (so that a new dependency):
- Enabled DHT stats when metrics collection is enabled
- Converted to
Metric
-compatible type when gathered - Added to heartbeat telementry event
Add libp2p prometheus metrics gathering. Supporting only counters and gauges (missing histograms, similarly to DHT).
Test Plan
Added unit tests for telemetryID/instanceName functionality. Added a unit test for stats similar to what DHT uses. Added a unit test for metrics similar to what libp2p uses.