Skip to content

feat: stream per-message flows through the collector - #83

Merged
AlexanderWangY merged 1 commit into
mainfrom
feat/collector-message-flows
Nov 19, 2026
Merged

AlexanderWangY merged 1 commit into
mainfrom
feat/collector-message-flows

Conversation

@AlexanderWangY

Copy link
Copy Markdown
Collaborator

What

Lets the collector see which node sent which node a message, so the viz can draw each message from sender to receiver.

  • Node (internal/node/flows.go): every send is counted by (peer, kind). Every 250 ms the counts go out as a FlowReport. Only when --collector-url is set.
  • Exporter (internal/telemetry/flows.go): posts each report to POST /v1/flows. Lossy on purpose: a busy channel or a failed post drops the batch, with no retry.
  • Collector (internal/collector/flows.go): validates the reports, merges them, and fans them out every 100 ms on GET /v1/flows/stream (SSE event flows, CORS open). It's a separate stream from /v1/graph/stream, so a burst of messages can't force graph viewers to resync. A slow subscriber misses batches rather than being disconnected. Nothing is buffered when nobody is subscribed.
  • wire: Kind.String() gives the stream readable kind names.

Event payload:

{"at":"…","flows":[{"from":"<id>","to":"<id>","kind":"heartbeat","count":1}]}

Load

Heartbeats dominate: every link sends one each way every 500 ms (about 470 per second on 24 nodes). Each node makes one small POST per 250 ms while it is sending anything.

Testing

  • New unit tests for node batching and drops, report validation, the hub's fan-out and slow subscribers, the HTTP POST to stream round trip, and the exporter. go test -race ./internal/... ./cmd/... passes.
  • End to end on a local 24-node cluster, viewed in visz (cap-theorem/visz, branch feat/message-flows).

🤖 Generated with Claude Code

Each node counts the messages it sends per peer and kind and posts them to POST /v1/flows every 250 ms when --collector-url is set. The collector merges them and fans them out every 100 ms on GET /v1/flows/stream, separate from the graph stream so a burst cannot force viewers to resync. Lossy by design: busy or failed batches are dropped.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@AlexanderWangY
AlexanderWangY merged commit a562f27 into main Nov 19, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant