feat(devshard): expose gateway chat cache size metric#1410
Closed
ouicate wants to merge 1 commit into
Closed
Conversation
The gateway chat cache exports no metrics, so operators can't see how many responses are cached or how occupancy tracks traffic -- every other gateway subsystem (limiter, capacity, participant limiter, host connections) already exposes gauges via gatewayMetricsCollector. Add a chatResponseCache.Len() accessor and a devshard_gateway_chat_cache_entries gauge, declared in Describe and emitted in Collect when chatCache is set. No labels (single process-wide cache); purely additive and read-only.
Contributor
|
@ouicate Please, take a look into PR #1402 and adjust your changes based on changes in #1402. One note: #1402 adds a Stats() accessor returning (entryCount, totalBytes) that overlaps this PR's Len(). Since #1402 bounds the cache by BYTES, if it lands first, rebasing onto Stats() and also exposing a bytes gauge (devshard_gateway_chat_cache_bytes) would match what actually caps the cache. |
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.
Problem
The gateway chat cache exports no metrics, so operators can't see how many responses are cached or how occupancy tracks traffic. Every other gateway subsystem (limiter, capacity, participant limiter, host connections) already exposes gauges via
gatewayMetricsCollector; the cache was the only unobservable one.Fix
Add a
chatResponseCache.Len()accessor and a new gaugedevshard_gateway_chat_cache_entriestogatewayMetricsCollector— declared inDescribe, emitted inCollectwhengateway.chatCache != nil. No labels(single process-wide cache). Purely additive, read-only, reuses the existing collector wiring.
Tests
TestGatewayMetricsCollectorReportsChatCacheEntriesseeds two entries and asserts the gauge reads 2 via the registry, following the existingrequireMetricGaugeValuepattern.Note
Companion to #1409 (which bounds the same cache). Independent of it: this PR only adds the accessor + gauge, so it applies cleanly on its own, and #1409 keeps the reported count bounded.