Skip to content

Commit 1f29044

Browse files
committed
Update PerfSession
1 parent 35f7753 commit 1f29044

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

firebase-perf/src/main/java/com/google/firebase/perf/session/PerfSession.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@ public static PerfSession createWithId(@Nullable String aqsSessionId) {
4040
if (sessionId == null) {
4141
sessionId = FirebaseSessionsHelperKt.createLegacySessionId();
4242
}
43-
PerfSession session = new PerfSession(sessionId, new Clock());
44-
session.setGaugeAndEventCollectionEnabled(session.shouldCollectGaugesAndEvents());
45-
return session;
43+
return new PerfSession(sessionId, new Clock());
4644
}
4745

4846
/** Creates a PerfSession with the provided {@code sessionId} and {@code clock}. */
4947
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
5048
public PerfSession(String sessionId, Clock clock) {
5149
this.sessionId = sessionId;
5250
creationTime = clock.getTime();
51+
isGaugeAndEventCollectionEnabled = shouldCollectGaugesAndEvents();
5352
}
5453

5554
private PerfSession(@NonNull Parcel in) {
@@ -72,14 +71,6 @@ public Timer getTimer() {
7271
return creationTime;
7372
}
7473

75-
/*
76-
* Enables/Disables the gauge and event collection for the system.
77-
*/
78-
public void setGaugeAndEventCollectionEnabled(boolean enabled) {
79-
// TODO(b/394127311): Explore deleting this method.
80-
isGaugeAndEventCollectionEnabled = enabled;
81-
}
82-
8374
/** Returns if the current session is verbose or not. */
8475
public boolean isVerbose() {
8576
return isGaugeAndEventCollectionEnabled;
@@ -146,13 +137,22 @@ public static com.google.firebase.perf.v1.PerfSession[] buildAndSort(
146137
}
147138

148139
/** If true, Session Gauge collection is enabled. */
140+
@VisibleForTesting
149141
public boolean shouldCollectGaugesAndEvents() {
150142
ConfigResolver configResolver = ConfigResolver.getInstance();
151143
return configResolver.isPerformanceMonitoringEnabled()
152144
&& (Math.abs(this.sessionId.hashCode() % 100)
153145
< configResolver.getSessionsSamplingRate() * 100);
154146
}
155147

148+
/*
149+
* Enables/Disables whether the session is verbose or not.
150+
*/
151+
@VisibleForTesting
152+
public void setGaugeAndEventCollectionEnabled(boolean enabled) {
153+
isGaugeAndEventCollectionEnabled = enabled;
154+
}
155+
156156
/**
157157
* Describes the kinds of special objects contained in this Parcelable's marshalled
158158
* representation. Please refer to

0 commit comments

Comments
 (0)