Skip to content

Commit a9a36d3

Browse files
committed
Switch to usage of AQS instead of sessions in most places
1 parent 030cd9a commit a9a36d3

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

firebase-perf/src/main/java/com/google/firebase/perf/FirebasePerfEarly.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.google.firebase.perf.application.AppStateMonitor;
2222
import com.google.firebase.perf.config.ConfigResolver;
2323
import com.google.firebase.perf.metrics.AppStartTrace;
24-
import com.google.firebase.perf.session.SessionManager;
2524
import java.util.concurrent.Executor;
2625

2726
/**
@@ -50,13 +49,5 @@ public FirebasePerfEarly(
5049
appStartTrace.registerActivityLifecycleCallbacks(context);
5150
uiExecutor.execute(new AppStartTrace.StartFromBackgroundRunnable(appStartTrace));
5251
}
53-
54-
// TODO: Bring back Firebase Sessions dependency to watch for updates to sessions.
55-
56-
// In the case of cold start, we create a session and start collecting gauges as early as
57-
// possible.
58-
// There is code in SessionManager that prevents us from resetting the session twice in case
59-
// of app cold start.
60-
SessionManager.getInstance().initializeGaugeCollection();
6152
}
6253
}

firebase-perf/src/main/java/com/google/firebase/perf/session/FirebasePerformanceSessionSubscriber.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class FirebasePerformanceSessionSubscriber(override val isDataCollectionEnabled:
3434
currentPerfSession.setAQSId(sessionDetails)
3535
GaugeManager.getInstance()
3636
.logGaugeMetadata(currentPerfSession.aqsSessionId(), ApplicationProcessState.FOREGROUND)
37+
// TODO(b/394127311): Explore deciding whether to collect gauges or not via. AQS.
38+
SessionManager.getInstance().initializeGaugeCollection()
3739
return
3840
}
3941

firebase-perf/src/main/java/com/google/firebase/perf/session/gauges/GaugeManager.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ public class GaugeManager {
5959
private final TransportManager transportManager;
6060

6161
@Nullable private GaugeMetadataManager gaugeMetadataManager;
62-
@Nullable private ScheduledFuture gaugeManagerDataCollectionJob = null;
62+
@Nullable private ScheduledFuture<?> gaugeManagerDataCollectionJob = null;
6363
@Nullable private String sessionId = null;
64+
@Nullable private String aqsSessionId = null;
6465
private ApplicationProcessState applicationProcessState =
6566
ApplicationProcessState.APPLICATION_PROCESS_STATE_UNKNOWN;
6667

@@ -130,10 +131,11 @@ public void startCollectingGauges(
130131
}
131132

132133
this.sessionId = session.sessionId();
134+
this.aqsSessionId = session.aqsSessionId();
133135
this.applicationProcessState = applicationProcessState;
134136

135137
// This is needed, otherwise the Runnable might use a stale value.
136-
final String sessionIdForScheduledTask = sessionId;
138+
final String sessionIdForScheduledTask = aqsSessionId;
137139
final ApplicationProcessState applicationProcessStateForScheduledTask = applicationProcessState;
138140

139141
// TODO(b/394127311): Switch to using AQS.
@@ -195,7 +197,7 @@ public void stopCollectingGauges() {
195197
}
196198

197199
// This is needed, otherwise the Runnable might use a stale value.
198-
final String sessionIdForScheduledTask = sessionId;
200+
final String sessionIdForScheduledTask = aqsSessionId;
199201
final ApplicationProcessState applicationProcessStateForScheduledTask = applicationProcessState;
200202

201203
cpuGaugeCollector.get().stopCollecting();
@@ -205,10 +207,9 @@ public void stopCollectingGauges() {
205207
gaugeManagerDataCollectionJob.cancel(false);
206208
}
207209

208-
// TODO(b/394127311): Switch to using AQS.
209210
// Flush any data that was collected for this session one last time.
210211
@SuppressWarnings("FutureReturnValueIgnored")
211-
ScheduledFuture unusedFuture =
212+
ScheduledFuture<?> unusedFuture =
212213
gaugeManagerExecutor
213214
.get()
214215
.schedule(

0 commit comments

Comments
 (0)