Skip to content

blockstream: count subscriptions closed because they were full - #93

Merged
sduchesneau merged 2 commits into
streamingfast:developfrom
pinax-network:feat/subscription-overflow-counter
Nov 13, 2026
Merged

sduchesneau merged 2 commits into
streamingfast:developfrom
pinax-network:feat/subscription-overflow-counter

Conversation

@matthewdarwin

Copy link
Copy Markdown
Contributor

Adds bstream_blockstream_subscriptions_closed_full_total, a counter of block stream subscriptions closed because they were full.

A subscriber (e.g. a relayer connected to a reader) that falls more blocks behind than the subscription channel size is disconnected (#91 made that size configurable). Until now this only showed as a reach max buffer size for subcription, closing channel log line, so there was nothing to graph or alert on.

Change

  • blockstream/metrics.go: a bstream_blockstream metric set with one counter, SubscriptionsClosedFull.
  • subscription.Push increments it inside the existing quitOnce, so each closed subscription counts once. Blocks pushed after the close aren't counted again.
  • NewUnmanagedServer (and so NewServer) registers the set. A process exports the counter only when it creates a block stream server, and then from 0. dmetrics.Set.Register ignores repeat calls.
  • No labels: the subscriber name comes from the client's request.
  • The ServerOptionWithSubscriptionChannelSize CHANGELOG entry from blockstream: make subscription channel size configurable #91 appeared twice under Unreleased, so I removed the duplicate.

The cost is one increment when a subscription is dropped, nothing per block.

Tested

  • TestBlockServerSubscriptionClosedWhenFull now also checks the counter: unchanged while the subscription holds up to its size, +1 when it closes, unchanged for blocks pushed after that.
  • New TestBlockServerRegistersMetrics: creating a server exports the counter through prometheus.DefaultGatherer.
  • End to end with firecore (v1.21.2 + this branch), reader-node-stdin + relayer with the default subscription size (200), a deliberately slow second subscriber and a 5,000-block burst: /metrics showed bstream_blockstream_subscriptions_closed_full_total 0 before the burst and 1 after, matching the single reach max buffer size log line.

🤖 Generated with Claude Code

A subscriber that falls more blocks behind than the subscription channel
size is disconnected, which so far only showed as a log line. Add
bstream_blockstream_subscriptions_closed_full_total, incremented once per
closed subscription and registered when a block stream server is created.

Also remove a duplicated CHANGELOG entry for
ServerOptionWithSubscriptionChannelSize.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dfuse-bot
dfuse-bot requested a review from billettc November 12, 2026 16:57
@sduchesneau
sduchesneau merged commit 713c833 into streamingfast:develop Nov 13, 2026
3 checks passed
sduchesneau pushed a commit to streamingfast/firehose-core that referenced this pull request Nov 13, 2026
Picks up streamingfast/bstream#93: bstream_blockstream_subscriptions_closed_full_total
counts subscribers (e.g. relayers) a reader disconnected because they fell
more blocks behind than the subscription channel size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants