Fix Prometheus gauge collision for cache_size metric#9729
Open
brucearctor wants to merge 1 commit intotemporalio:mainfrom
Open
Fix Prometheus gauge collision for cache_size metric#9729brucearctor wants to merge 1 commit intotemporalio:mainfrom
brucearctor wants to merge 1 commit intotemporalio:mainfrom
Conversation
The replication progress cache was reusing MutableStateCacheTypeTagValue as its metrics tag, causing its cache_size gauge to overwrite the mutable state cache's gauge (Prometheus last-write-wins). This made it impossible to monitor the actual mutable state cache capacity. Add a dedicated ReplicationProgressCacheTypeTagValue constant and use it in the progress cache, so both caches report their cache_size independently via distinct cache_type label values. Fixes temporalio#9600
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.
What Changed
The replication progress cache was reusing
MutableStateCacheTypeTagValueas itscache_typemetrics tag, causing itscache_sizegauge to overwrite the mutable state cache's gauge via Prometheus last-write-wins semantics.This made
cache_size{cache_type="mutablestate"}always report128000(the replication progress cache's default size) instead of the actual mutable state cache capacity — particularly misleading whencacheSizeBasedLimit: trueis configured.Fix
ReplicationProgressCacheTypeTagValue = "replication_progress"constant incommon/metrics/metric_defs.goservice/history/replication/progress_cache.goinstead ofMutableStateCacheTypeTagValuecache_typetag valueBoth caches now report their
cache_sizeindependently via distinctcache_typelabel values.Why
This is a one-line behavioral change (plus the new constant and test). It only affects metric label values — no logic, API surface, or persistence changes.
Fixes #9600