Skip to content

Commit 88f31b6

Browse files
runningcodeclaude
andcommitted
ref(core): Read the collection ticker from options
Drop the package-private constructor overload that took a MonotonicTicker and read options.getMonotonicTicker() instead. The test overrides getMonotonicTicker() on a SentryOptions subclass, as SentryOptionsTest already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4233ff7 commit 88f31b6

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

‎sentry/src/main/java/io/sentry/DefaultCompositePerformanceCollector.java‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.sentry;
22

33
import io.sentry.time.Deadline;
4-
import io.sentry.time.MonotonicTicker;
54
import io.sentry.util.AutoClosableReentrantLock;
65
import io.sentry.util.Objects;
76
import java.util.ArrayList;
@@ -28,19 +27,10 @@ public final class DefaultCompositePerformanceCollector implements CompositePerf
2827
private final boolean hasNoCollectors;
2928

3029
private final @NotNull SentryOptions options;
31-
private final @NotNull MonotonicTicker ticker;
3230
private final @NotNull AtomicBoolean isStarted = new AtomicBoolean(false);
3331

3432
public DefaultCompositePerformanceCollector(final @NotNull SentryOptions options) {
35-
this(
36-
Objects.requireNonNull(options, "The options object is required."),
37-
options.getMonotonicTicker());
38-
}
39-
40-
DefaultCompositePerformanceCollector(
41-
final @NotNull SentryOptions options, final @NotNull MonotonicTicker ticker) {
4233
this.options = Objects.requireNonNull(options, "The options object is required.");
43-
this.ticker = Objects.requireNonNull(ticker, "The ticker is required.");
4434
this.snapshotCollectors = new ArrayList<>();
4535
this.continuousCollectors = new ArrayList<>();
4636

@@ -231,7 +221,10 @@ private CompositeData(final @Nullable ITransaction transaction) {
231221
// On a ticker rather than the date provider: this is how long we have been collecting, and
232222
// a device time change must not end a collection early or keep a finished one going.
233223
this.collectUntil =
234-
Deadline.after(ticker, TRANSACTION_COLLECTION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
224+
Deadline.after(
225+
options.getMonotonicTicker(),
226+
TRANSACTION_COLLECTION_TIMEOUT_MILLIS,
227+
TimeUnit.MILLISECONDS);
235228
}
236229

237230
/**

‎sentry/src/test/java/io/sentry/DefaultCompositePerformanceCollectorTest.kt‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package io.sentry
33
import io.sentry.test.getCtor
44
import io.sentry.test.getProperty
55
import io.sentry.test.injectForField
6+
import io.sentry.time.MonotonicTicker
67
import io.sentry.time.TestMonotonicTicker
78
import io.sentry.util.thread.ThreadChecker
89
import java.util.Timer
@@ -34,8 +35,11 @@ class DefaultCompositePerformanceCollectorTest {
3435
lateinit var transaction2: ITransaction
3536
val id1 = "id1"
3637
val scopes: IScopes = mock()
37-
val options = SentryOptions()
3838
val ticker = TestMonotonicTicker()
39+
val options =
40+
object : SentryOptions() {
41+
override fun getMonotonicTicker(): MonotonicTicker = ticker
42+
}
3943
var mockTimer: Timer? = null
4044

4145
val mockCpuCollector: IPerformanceSnapshotCollector =
@@ -67,7 +71,7 @@ class DefaultCompositePerformanceCollectorTest {
6771
optionsConfiguration.configure(options)
6872
transaction1 = SentryTracer(TransactionContext("", ""), scopes)
6973
transaction2 = SentryTracer(TransactionContext("", ""), scopes)
70-
val collector = DefaultCompositePerformanceCollector(options, ticker)
74+
val collector = DefaultCompositePerformanceCollector(options)
7175
val timer: Timer = collector.getProperty("timer") ?: Timer(true)
7276
mockTimer = spy(timer)
7377
collector.injectForField("timer", mockTimer)

0 commit comments

Comments
 (0)