Skip to content

Commit

Permalink
Properly reset metric flush flag on metric emission (#3493)
Browse files Browse the repository at this point in the history
* Fix schedule flag reset

* Update changelog
  • Loading branch information
markushi authored Jun 18, 2024
1 parent 051ce9b commit 133f63e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

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

## 7.10.0

Expand Down
2 changes: 2 additions & 0 deletions sentry/src/main/java/io/sentry/MetricsAggregator.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ public void flush(boolean force) {
force = true;
}

flushScheduled = false;

final @NotNull Set<Long> flushableBuckets = getFlushableBuckets(force);
if (flushableBuckets.isEmpty()) {
logger.log(SentryLevel.DEBUG, "Metrics: nothing to flush");
Expand Down
13 changes: 13 additions & 0 deletions sentry/src/test/java/io/sentry/MetricsAggregatorTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,19 @@ class MetricsAggregatorTest {

// there is no other metric to capture, so flush is not scheduled again
assertFalse(fixture.executorService.hasScheduledRunnables())

// once another metric is emitted
aggregator.increment(
"name1",
1.0,
MeasurementUnit.Custom("unit0"),
mapOf("key0" to "value0"),
20_001,
null
)

// then flush should be scheduled again
assertTrue(fixture.executorService.hasScheduledRunnables())
}

@Test
Expand Down

0 comments on commit 133f63e

Please sign in to comment.