use of com.google.firebase.perf.session.SessionManager in project firebase-android-sdk by firebase.
the class NetworkRequestMetricBuilder method setRequestStartTimeMicros.
/**
* Sets the clientStartTimeUs for the current {@link NetworkRequestMetric}.
*
* <p>Note: The start of the request also trigger collection of a single {@link GaugeMetric} data
* point depending upon the current {@link PerfSession} verbosity.
*
* @see GaugeManager#collectGaugeMetricOnce(Timer)
* @see PerfSession#isGaugeAndEventCollectionEnabled()
*/
public NetworkRequestMetricBuilder setRequestStartTimeMicros(long time) {
SessionManager sessionManager = SessionManager.getInstance();
PerfSession perfSession = sessionManager.perfSession();
SessionManager.getInstance().registerForSessionUpdates(weakReference);
builder.setClientStartTimeUs(time);
updateSession(perfSession);
if (perfSession.isGaugeAndEventCollectionEnabled()) {
gaugeManager.collectGaugeMetricOnce(perfSession.getTimer());
}
return this;
}
use of com.google.firebase.perf.session.SessionManager in project firebase-android-sdk by firebase.
the class TraceTest method testSessionIdNotAddedIfPerfSessionIsNull.
@Test
public void testSessionIdNotAddedIfPerfSessionIsNull() {
Trace trace = Trace.getTrace("myRandomTrace4");
trace.start();
assertThat(trace.getSessions()).isNotNull();
int numberOfSessionIds = trace.getSessions().size();
new SessionManager(mock(GaugeManager.class), null, mock(AppStateMonitor.class)).onUpdateAppState(ApplicationProcessState.FOREGROUND);
assertThat(trace.getSessions()).hasSize(numberOfSessionIds);
trace.stop();
}
use of com.google.firebase.perf.session.SessionManager in project firebase-android-sdk by firebase.
the class NetworkRequestMetricBuilderTest method testSessionIdNotAddedIfPerfSessionIsNull.
@Test
public void testSessionIdNotAddedIfPerfSessionIsNull() {
NetworkRequestMetricBuilder metricBuilder = NetworkRequestMetricBuilder.builder(mockTransportManager);
metricBuilder.setRequestStartTimeMicros(/* time= */
2000);
assertThat(this.networkMetricBuilder.getSessions()).isNotNull();
assertThat(this.networkMetricBuilder.getSessions()).isEmpty();
int numberOfSessionIds = metricBuilder.getSessions().size();
new SessionManager(mock(GaugeManager.class), null, mock(AppStateMonitor.class)).onUpdateAppState(ApplicationProcessState.FOREGROUND);
assertThat(metricBuilder.getSessions()).hasSize(numberOfSessionIds);
}
use of com.google.firebase.perf.session.SessionManager in project firebase-android-sdk by firebase.
the class Trace method start.
/**
* Starts this trace.
*/
@Keep
public void start() {
if (!ConfigResolver.getInstance().isPerformanceMonitoringEnabled()) {
logger.debug("Trace feature is disabled.");
return;
}
String err = validateTraceName(name);
if (err != null) {
logger.error("Cannot start trace '%s'. Trace name is invalid.(%s)", name, err);
return;
}
if (startTime != null) {
logger.error("Trace '%s' has already started, should not start again!", name);
return;
}
startTime = clock.getTime();
registerForAppState();
SessionManager sessionManager = SessionManager.getInstance();
PerfSession perfSession = sessionManager.perfSession();
SessionManager.getInstance().registerForSessionUpdates(sessionAwareObject);
updateSession(perfSession);
if (perfSession.isGaugeAndEventCollectionEnabled()) {
gaugeManager.collectGaugeMetricOnce(perfSession.getTimer());
}
}
Aggregations