Commit 091edfd
authored
metrics: fix section_filter no-op on scalars (operator precedence) (#533)
`if collect and type(v) is float or type(v) is int:` parsed as
`(collect and type(v) is float) or (type(v) is int)` due to Python's
`and`/`or` precedence, so the `collect` flag -- which carries the
section_filter decision -- was effectively ignored whenever the value
was an int. Every int-valued INFO key leaked past the filter and into
the overall map, regardless of whether the caller had whitelisted it.
Parenthesize to `if collect and (type(v) is float or type(v) is int):`
so the filter actually filters scalars too.
Impact: callers of `collect_redis_metrics` that pass a `section_filter`
now get exactly the keys they asked for. In particular,
`collect_search_and_bigredis_metrics` (0.12.27) was silently pulling
every scalar from bigredis / search_memory / search_disk instead of the
four it lists. With this fix it returns strictly the documented keys.
Adds two mock-based regression tests:
- test_collect_redis_metrics_section_filter_drops_scalar_keys: the
intended semantics -- only whitelisted keys survive.
- test_collect_redis_metrics_no_filter_keeps_all_scalars: legacy
default path (no filter) still collects every scalar.
Bumps pyproject.toml 0.12.26 -> 0.12.28 (skipping .27 which is in
#531's pipeline).1 parent dcad735 commit 091edfd
3 files changed
Lines changed: 62 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
92 | 137 | | |
93 | 138 | | |
94 | 139 | | |
95 | 140 | | |
96 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
97 | 146 | | |
98 | 147 | | |
99 | 148 | | |
100 | 149 | | |
101 | 150 | | |
| 151 | + | |
| 152 | + | |
102 | 153 | | |
103 | 154 | | |
104 | 155 | | |
| 156 | + | |
| 157 | + | |
105 | 158 | | |
106 | 159 | | |
107 | 160 | | |
108 | 161 | | |
109 | 162 | | |
110 | 163 | | |
111 | 164 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
116 | 171 | | |
117 | 172 | | |
118 | 173 | | |
| |||
0 commit comments