use of com.google.firebase.perf.v1.PerfSession in project firebase-android-sdk by firebase.
the class TransportManagerTest method logTraceMetric_sessionEnabled_doesNotStripOffSessionId.
// endregion
// region Session's Behaviour
@Test
public void logTraceMetric_sessionEnabled_doesNotStripOffSessionId() {
TraceMetric.Builder validTrace = createValidTraceMetric().toBuilder();
List<PerfSession> perfSessions = new ArrayList<>();
perfSessions.add(new com.google.firebase.perf.session.PerfSession("fakeSessionId", new Clock()).build());
validTrace.addAllPerfSessions(perfSessions);
testTransportManager.log(validTrace.build());
fakeExecutorService.runAll();
PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
assertThat(loggedPerfMetric.getTraceMetric().getPerfSessionsCount()).isEqualTo(1);
assertThat(loggedPerfMetric.getTraceMetric().getPerfSessions(0).getSessionId()).isEqualTo("fakeSessionId");
}
use of com.google.firebase.perf.v1.PerfSession in project firebase-android-sdk by firebase.
the class TransportManagerTest method logNetworkMetric_sessionEnabled_doesNotStripOffSessionId.
@Test
public void logNetworkMetric_sessionEnabled_doesNotStripOffSessionId() {
NetworkRequestMetric.Builder validNetworkRequest = createValidNetworkRequestMetric().toBuilder();
List<PerfSession> perfSessions = new ArrayList<>();
perfSessions.add(new com.google.firebase.perf.session.PerfSession("fakeSessionId", new Clock()).build());
validNetworkRequest.clearPerfSessions().addAllPerfSessions(perfSessions);
testTransportManager.log(validNetworkRequest.build());
fakeExecutorService.runAll();
PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
assertThat(loggedPerfMetric.getNetworkRequestMetric().getPerfSessionsCount()).isEqualTo(1);
assertThat(loggedPerfMetric.getNetworkRequestMetric().getPerfSessions(0).getSessionId()).isEqualTo("fakeSessionId");
}
use of com.google.firebase.perf.v1.PerfSession in project firebase-android-sdk by firebase.
the class GaugeManagerTest method testStartCollectingGaugesStartsAJobToConsumeTheGeneratedMetrics.
@Test
public void testStartCollectingGaugesStartsAJobToConsumeTheGeneratedMetrics() {
PerfSession fakeSession = new PerfSession("sessionId", new Clock());
testGaugeManager.startCollectingGauges(fakeSession, ApplicationProcessState.BACKGROUND);
assertThat(fakeScheduledExecutorService.isEmpty()).isFalse();
assertThat(fakeScheduledExecutorService.getDelayToNextTask(TimeUnit.MILLISECONDS)).isEqualTo(getMinimumBackgroundCollectionFrequency() * APPROX_NUMBER_OF_DATA_POINTS_PER_GAUGE_METRIC);
CpuMetricReading fakeCpuMetricReading1 = createFakeCpuMetricReading(200, 100);
CpuMetricReading fakeCpuMetricReading2 = createFakeCpuMetricReading(300, 200);
fakeCpuGaugeCollector.cpuMetricReadings.add(fakeCpuMetricReading1);
fakeCpuGaugeCollector.cpuMetricReadings.add(fakeCpuMetricReading2);
AndroidMemoryReading fakeMemoryMetricReading1 = createFakeAndroidMetricReading(/* currentUsedAppJavaHeapMemoryKb= */
123456);
AndroidMemoryReading fakeMemoryMetricReading2 = createFakeAndroidMetricReading(/* currentUsedAppJavaHeapMemoryKb= */
23454678);
fakeMemoryGaugeCollector.memoryMetricReadings.add(fakeMemoryMetricReading1);
fakeMemoryGaugeCollector.memoryMetricReadings.add(fakeMemoryMetricReading2);
fakeScheduledExecutorService.simulateSleepExecutingAtMostOneTask();
GaugeMetric recordedGaugeMetric = getLastRecordedGaugeMetric(ApplicationProcessState.BACKGROUND, 1);
assertThatCpuGaugeMetricWasSentToTransport("sessionId", recordedGaugeMetric, fakeCpuMetricReading1, fakeCpuMetricReading2);
assertThatMemoryGaugeMetricWasSentToTransport("sessionId", recordedGaugeMetric, fakeMemoryMetricReading1, fakeMemoryMetricReading2);
}
Aggregations