Skip to content

Commit 7946816

Browse files
committed
performance data collection is now started only when the transaction is sampled
1 parent 27d7cf8 commit 7946816

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

sentry/src/main/java/io/sentry/SentryTracer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public SentryTracer(
9090
}
9191

9292
// We are currently sending the performance data only in profiles, but we are always sending
93-
// performance measurements.
94-
if (compositePerformanceCollector != null) {
93+
// performance measurements (frames data in spans).
94+
if (compositePerformanceCollector != null && Boolean.TRUE.equals(isSampled())) {
9595
compositePerformanceCollector.start(this);
9696
}
9797

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,12 @@ class SentryTracerTest {
11751175
verify(fixture.compositePerformanceCollector).start(anyOrNull<ITransaction>())
11761176
}
11771177

1178+
@Test
1179+
fun `when transaction is created, but not sampled, compositePerformanceCollector is not started`() {
1180+
val transaction = fixture.getSut(samplingDecision = TracesSamplingDecision(false))
1181+
verify(fixture.compositePerformanceCollector, never()).start(anyOrNull<ITransaction>())
1182+
}
1183+
11781184
@Test
11791185
fun `when transaction is created and profiled compositePerformanceCollector is started`() {
11801186
val transaction =

0 commit comments

Comments
 (0)