Commit c2df331
Fix Prometheus gauge collision for cache_size metric (#9729)
## What Changed
The replication progress cache was reusing
`MutableStateCacheTypeTagValue` as its `cache_type` metrics tag, causing
its `cache_size` gauge to overwrite the mutable state cache's gauge via
Prometheus last-write-wins semantics.
This made `cache_size{cache_type="mutablestate"}` always report `128000`
(the replication progress cache's default size) instead of the actual
mutable state cache capacity — particularly misleading when
`cacheSizeBasedLimit: true` is configured.
## Fix
- Add a new `ReplicationProgressCacheTypeTagValue =
"replication_progress"` constant in `common/metrics/metric_defs.go`
- Use it in `service/history/replication/progress_cache.go` instead of
`MutableStateCacheTypeTagValue`
- Add a unit test verifying the progress cache uses a distinct
`cache_type` tag value
Both caches now report their `cache_size` independently via distinct
`cache_type` label 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
Co-authored-by: Jiechen Zhong <jiechen.zhong@temporal.io>1 parent 7e96477 commit c2df331
3 files changed
Lines changed: 40 additions & 1 deletion
File tree
- common/metrics
- service/history/replication
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
0 commit comments