Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly reset metric flush flag on metric emission #3493

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading