Commit ab22674
fix(opentelemetry-sdk): keep synchronous gauge values across cumulative collections (#5637)
* fix(opentelemetry-sdk): keep synchronous gauge values across cumulative collections
The MetricReader spec requires that for synchronous instruments with
cumulative aggregation temporality, Collect receives the data points
exposed in previous collections regardless of whether new measurements
have been recorded:
https://opentelemetry.io/docs/specs/otel/metrics/sdk/#metricreader
_LastValueAggregation dropped its value on every collection, so a
synchronous gauge disappeared from the export as soon as one collection
interval passed without a set() call.
Fixes #4512
Fixes #3971
* chore(changelog): rename fragment to match PR number
* chore(changelog): apply reviewer wording to 5637 fragment
* test(opentelemetry-sdk): cover synchronous gauge persistence via InMemoryMetricReader
Collecting twice through an InMemoryMetricReader without recording a new
measurement in between must still export the gauge with its last value.
---------
Co-authored-by: Emídio <9735060+emdneto@users.noreply.github.com>1 parent 477ffd4 commit ab22674
5 files changed
Lines changed: 85 additions & 10 deletions
File tree
- .changelog
- opentelemetry-sdk
- src/opentelemetry/sdk/metrics/_internal
- tests/metrics
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
| 372 | + | |
372 | 373 | | |
373 | 374 | | |
| 375 | + | |
374 | 376 | | |
375 | 377 | | |
376 | 378 | | |
| |||
391 | 393 | | |
392 | 394 | | |
393 | 395 | | |
394 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
395 | 401 | | |
396 | 402 | | |
397 | 403 | | |
| |||
1171 | 1177 | | |
1172 | 1178 | | |
1173 | 1179 | | |
| 1180 | + | |
1174 | 1181 | | |
1175 | 1182 | | |
1176 | 1183 | | |
1177 | 1184 | | |
1178 | 1185 | | |
1179 | 1186 | | |
| 1187 | + | |
1180 | 1188 | | |
1181 | 1189 | | |
1182 | 1190 | | |
| |||
1329 | 1337 | | |
1330 | 1338 | | |
1331 | 1339 | | |
| 1340 | + | |
1332 | 1341 | | |
1333 | 1342 | | |
1334 | 1343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
214 | 218 | | |
215 | 219 | | |
216 | 220 | | |
| |||
226 | 230 | | |
227 | 231 | | |
228 | 232 | | |
229 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
230 | 238 | | |
231 | 239 | | |
232 | 240 | | |
| |||
240 | 248 | | |
241 | 249 | | |
242 | 250 | | |
243 | | - | |
| 251 | + | |
244 | 252 | | |
245 | 253 | | |
246 | 254 | | |
| |||
249 | 257 | | |
250 | 258 | | |
251 | 259 | | |
252 | | - | |
| 260 | + | |
253 | 261 | | |
254 | 262 | | |
255 | 263 | | |
| |||
258 | 266 | | |
259 | 267 | | |
260 | 268 | | |
261 | | - | |
| 269 | + | |
262 | 270 | | |
263 | 271 | | |
264 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
265 | 307 | | |
266 | 308 | | |
267 | 309 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
0 commit comments