Skip to content

Commit 133f63e

Browse files
authored
Properly reset metric flush flag on metric emission (#3493)
* Fix schedule flag reset * Update changelog
1 parent 051ce9b commit 133f63e

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- Remove profiling timeout logic and disable profiling on API 21 ([#3478](https://github.com/getsentry/sentry-java/pull/3478))
8+
- Properly reset metric flush flag on metric emission ([#3493](https://github.com/getsentry/sentry-java/pull/3493))
89

910
## 7.10.0
1011

sentry/src/main/java/io/sentry/MetricsAggregator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ public void flush(boolean force) {
239239
force = true;
240240
}
241241

242+
flushScheduled = false;
243+
242244
final @NotNull Set<Long> flushableBuckets = getFlushableBuckets(force);
243245
if (flushableBuckets.isEmpty()) {
244246
logger.log(SentryLevel.DEBUG, "Metrics: nothing to flush");

sentry/src/test/java/io/sentry/MetricsAggregatorTest.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,19 @@ class MetricsAggregatorTest {
312312

313313
// there is no other metric to capture, so flush is not scheduled again
314314
assertFalse(fixture.executorService.hasScheduledRunnables())
315+
316+
// once another metric is emitted
317+
aggregator.increment(
318+
"name1",
319+
1.0,
320+
MeasurementUnit.Custom("unit0"),
321+
mapOf("key0" to "value0"),
322+
20_001,
323+
null
324+
)
325+
326+
// then flush should be scheduled again
327+
assertTrue(fixture.executorService.hasScheduledRunnables())
315328
}
316329

317330
@Test

0 commit comments

Comments
 (0)