use of com.google.firebase.perf.v1.GaugeMetric in project firebase-android-sdk by firebase.
the class TransportManagerTest method validGaugeMetric_unknownApplicationProcessState_getLogged.
@Test
public void validGaugeMetric_unknownApplicationProcessState_getLogged() {
GaugeMetric validGauge = createValidGaugeMetric();
testTransportManager.log(validGauge);
fakeExecutorService.runAll();
PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
assertThat(loggedPerfMetric.getGaugeMetric()).isEqualTo(validGauge);
validateApplicationInfo(loggedPerfMetric, ApplicationProcessState.APPLICATION_PROCESS_STATE_UNKNOWN);
}
use of com.google.firebase.perf.v1.GaugeMetric in project firebase-android-sdk by firebase.
the class TransportManagerTest method logGaugeMetric_globalCustomAttributesAreNotAdded.
@Test
public void logGaugeMetric_globalCustomAttributesAreNotAdded() {
FirebasePerformance.getInstance().putAttribute("test_key1", "test_value1");
FirebasePerformance.getInstance().putAttribute("test_key2", "test_value2");
GaugeMetric validGauge = createValidGaugeMetric();
testTransportManager.log(validGauge);
fakeExecutorService.runAll();
PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
assertThat(loggedPerfMetric.getGaugeMetric()).isEqualTo(validGauge);
validateApplicationInfo(loggedPerfMetric, ApplicationProcessState.APPLICATION_PROCESS_STATE_UNKNOWN);
assertThat(loggedPerfMetric.getApplicationInfo().getCustomAttributesCount()).isEqualTo(0);
}
use of com.google.firebase.perf.v1.GaugeMetric 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