Repository navigation
feat(api): serve real stats from a background sampler - #55
Merged
Merged
Conversation
/api/v1/stats/* answered 503 and /metrics had no filesystem metrics because mount never set a stats provider. internal/stats now has a Sampler that copies the cache, lock, journal and TRIM counters every second and reads the block bitmap and node registry every 15 seconds. Requests, including the unauthenticated /metrics, only load the latest snapshot. /api/v1/status takes its capacity from the same snapshot instead of scanning the bitmap per request. - lock.Manager.Stats: held keys, waiting Acquire calls, hint cache size - trim.Stats: failed discard ranges, last discard time, batch size - node.Registry.Slots no longer holds the registry mutex across 64 reads - SFB stays disabled: /stats/sfb answers 404 and no sfb_* metrics - goclusterfs_journal_state maps clean/dirty/recovering/corrupt; the old "open" value never occurred - new goclusterfs_fs_size_bytes and goclusterfs_fs_free_bytes - removes the unused stats.Collector Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mattmattox
added a commit
that referenced
this pull request
Nov 10, 2026
…nts honest (#58) Review follow-ups for #55: - The sampler reads the block bitmap and node registry only while requests read capacity or cluster data; an idle mount no longer scans the bitmap every 15 seconds. The first request after a quiet period starts a read. - pending_locks counts only Acquire calls whose first attempt found the lock taken, not every uncontended acquire in flight. - TRIM no longer counts EOPNOTSUPP/ENOTTY ranges as discarded. The device is marked unsupported and trim_enabled reports false. A flush the bitmap guard refuses now counts as an error. - Rename the cache stats variable that shadowed the stats package. - The two API integration tests are high priority with Docker/VM TODOs. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mount now sets a stats provider, so
/api/v1/stats/*stops answering 503 and/metricsexports cache, journal, TRIM, lock, cluster and capacity values.Reviewer notes:
/metricsneeds no auth, so requests only read a snapshot. Counters refresh every 1s; the bitmap and node registry are read every 15s.sfbfields describe block allocation, but SFB containers are disabled, so/stats/sfbanswers 404 and there are nosfb_*metrics. Capacity isgoclusterfs_fs_{size,free}_bytes.goclusterfs_journal_statechanged meaning: the oldopenvalue never occurred.ClusterNodes/ClusterLockstoStatsProvider; the Sampler needs them once both land.Testing on .68: lint 0 issues, race unit 20/20 packages, TestAPIStatsReportLiveValues and TestAPIServesHealthOnLoopback pass (load 341).
🤖 Generated with Claude Code