Search in sources :

Example 16 with GaugeMetric

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);
}
Also used : PerfMetric(com.google.firebase.perf.v1.PerfMetric) GaugeMetric(com.google.firebase.perf.v1.GaugeMetric) Test(org.junit.Test)

Example 17 with GaugeMetric

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);
}
Also used : PerfMetric(com.google.firebase.perf.v1.PerfMetric) GaugeMetric(com.google.firebase.perf.v1.GaugeMetric) Test(org.junit.Test)

Example 18 with GaugeMetric

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);
}
Also used : AndroidMemoryReading(com.google.firebase.perf.v1.AndroidMemoryReading) CpuMetricReading(com.google.firebase.perf.v1.CpuMetricReading) PerfSession(com.google.firebase.perf.session.PerfSession) GaugeMetric(com.google.firebase.perf.v1.GaugeMetric) Clock(com.google.firebase.perf.util.Clock) Test(org.junit.Test)

Aggregations

GaugeMetric (com.google.firebase.perf.v1.GaugeMetric)18 Test (org.junit.Test)17 PerfMetric (com.google.firebase.perf.v1.PerfMetric)10 AndroidMemoryReading (com.google.firebase.perf.v1.AndroidMemoryReading)6 CpuMetricReading (com.google.firebase.perf.v1.CpuMetricReading)6 PerfSession (com.google.firebase.perf.session.PerfSession)5 Clock (com.google.firebase.perf.util.Clock)5 ApplicationProcessState (com.google.firebase.perf.v1.ApplicationProcessState)3 GaugeMetadata (com.google.firebase.perf.v1.GaugeMetadata)3 ArrayList (java.util.ArrayList)2 Lazy (com.google.firebase.components.Lazy)1 NetworkRequestMetric (com.google.firebase.perf.v1.NetworkRequestMetric)1 TraceMetric (com.google.firebase.perf.v1.TraceMetric)1