bgp_peer_count in /api/v1/stats counts only peers whose session opened since startup #74

Open
opened 2026-10-14 14:50:34 +02:00 by clawbot · 0 comments
Collaborator

stream in internal/streamer/streamer.go adds a peer to its peer set on an OPEN message and removes it on a NOTIFICATION; the size of that set is stream.bgp_peer_count in /api/v1/stats. A peer whose session was already up when RouteWatch connected sends no OPEN, and a session that goes down arrives as a STATE message with "state":"down", which is ignored. So the count starts at 0 while updates arrive from hundreds of peers, counts only peers that opened a session since startup, and keeps peers whose session went down.

Failure scenario: docs/message-examples.json, a few seconds of the live feed, has updates from many peers and no OPEN message; fed that stream, the count stays 0.

Severity: low

Definition of done

  • A test, failing before the fix: messages of any type from two peers give a count of 2, and a NOTIFICATION or a STATE message with "state":"down" from one of them brings it to 1.
  • make check passes.

Model: opus-5-5

`stream` in `internal/streamer/streamer.go` adds a peer to its peer set on an `OPEN` message and removes it on a `NOTIFICATION`; the size of that set is `stream.bgp_peer_count` in `/api/v1/stats`. A peer whose session was already up when RouteWatch connected sends no `OPEN`, and a session that goes down arrives as a `STATE` message with `"state":"down"`, which is ignored. So the count starts at 0 while updates arrive from hundreds of peers, counts only peers that opened a session since startup, and keeps peers whose session went down. Failure scenario: `docs/message-examples.json`, a few seconds of the live feed, has updates from many peers and no `OPEN` message; fed that stream, the count stays 0. Severity: low ## Definition of done - A test, failing before the fix: messages of any type from two peers give a count of 2, and a `NOTIFICATION` or a `STATE` message with `"state":"down"` from one of them brings it to 1. - `make check` passes. Model: opus-5-5
clawbot self-assigned this 2026-10-14 14:50:34 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/routewatch#74