use of com.google.firebase.perf.v1.GaugeMetadata in project firebase-android-sdk by firebase.
the class GaugeManager method logGaugeMetadata.
/**
* Log the Gauge Metadata information to the transport.
*
* @param sessionId The {@link PerfSession#sessionId()} to which the collected Gauge Metrics
* should be associated with.
* @param appState The {@link ApplicationProcessState} for which these gauges are collected.
* @return true if GaugeMetadata was logged, false otherwise.
*/
public boolean logGaugeMetadata(String sessionId, ApplicationProcessState appState) {
if (gaugeMetadataManager != null) {
GaugeMetric gaugeMetric = GaugeMetric.newBuilder().setSessionId(sessionId).setGaugeMetadata(getGaugeMetadata()).build();
transportManager.log(gaugeMetric, appState);
return true;
}
return false;
}
use of com.google.firebase.perf.v1.GaugeMetadata in project firebase-android-sdk by firebase.
the class GaugeManagerTest method testLogGaugeMetadataSendDataToTransport.
@Test
public void testLogGaugeMetadataSendDataToTransport() {
when(fakeGaugeMetadataManager.getProcessName()).thenReturn("processName");
when(fakeGaugeMetadataManager.getDeviceRamSizeKb()).thenReturn(2000);
when(fakeGaugeMetadataManager.getMaxAppJavaHeapMemoryKb()).thenReturn(1000);
when(fakeGaugeMetadataManager.getMaxEncouragedAppJavaHeapMemoryKb()).thenReturn(800);
testGaugeManager.logGaugeMetadata("sessionId", ApplicationProcessState.FOREGROUND);
GaugeMetric recordedGaugeMetric = getLastRecordedGaugeMetric(ApplicationProcessState.FOREGROUND, 1);
GaugeMetadata recordedGaugeMetadata = recordedGaugeMetric.getGaugeMetadata();
assertThat(recordedGaugeMetric.getSessionId()).isEqualTo("sessionId");
assertThat(recordedGaugeMetadata.getProcessName()).isEqualTo("processName");
assertThat(recordedGaugeMetadata.getDeviceRamSizeKb()).isEqualTo(fakeGaugeMetadataManager.getDeviceRamSizeKb());
assertThat(recordedGaugeMetadata.getMaxAppJavaHeapMemoryKb()).isEqualTo(fakeGaugeMetadataManager.getMaxAppJavaHeapMemoryKb());
assertThat(recordedGaugeMetadata.getMaxEncouragedAppJavaHeapMemoryKb()).isEqualTo(fakeGaugeMetadataManager.getMaxEncouragedAppJavaHeapMemoryKb());
}
use of com.google.firebase.perf.v1.GaugeMetadata in project firebase-android-sdk by firebase.
the class GaugeManagerTest method testLogGaugeMetadataLogsAfterApplicationContextIsSet.
@Test
public void testLogGaugeMetadataLogsAfterApplicationContextIsSet() {
testGaugeManager = new GaugeManager(new Lazy<>(() -> fakeScheduledExecutorService), mockTransportManager, mockConfigResolver, /* gaugeMetadataManager= */
null, new Lazy<>(() -> fakeCpuGaugeCollector), new Lazy<>(() -> fakeMemoryGaugeCollector));
assertThat(testGaugeManager.logGaugeMetadata("sessionId", ApplicationProcessState.FOREGROUND)).isFalse();
testGaugeManager.initializeGaugeMetadataManager(ApplicationProvider.getApplicationContext());
assertThat(testGaugeManager.logGaugeMetadata("sessionId", ApplicationProcessState.FOREGROUND)).isTrue();
GaugeMetric recordedGaugeMetric = getLastRecordedGaugeMetric(ApplicationProcessState.FOREGROUND, 1);
GaugeMetadata recordedGaugeMetadata = recordedGaugeMetric.getGaugeMetadata();
assertThat(recordedGaugeMetric.getSessionId()).isEqualTo("sessionId");
assertThat(recordedGaugeMetadata.hasProcessName()).isTrue();
}
use of com.google.firebase.perf.v1.GaugeMetadata in project firebase-android-sdk by firebase.
the class TransportManagerTest method validGaugeMetric_withMetadata_isLogged.
@Test
public void validGaugeMetric_withMetadata_isLogged() {
ApplicationProcessState expectedAppState = ApplicationProcessState.FOREGROUND;
GaugeMetadata gaugeMetadata = GaugeMetadata.newBuilder().setDeviceRamSizeKb(2000).setMaxAppJavaHeapMemoryKb(1000).setMaxEncouragedAppJavaHeapMemoryKb(800).build();
GaugeMetric validGauge = GaugeMetric.newBuilder().setSessionId("sessionId").setGaugeMetadata(gaugeMetadata).build();
testTransportManager.log(validGauge, expectedAppState);
fakeExecutorService.runAll();
PerfMetric loggedPerfMetric = getLastLoggedEvent(times(1));
assertThat(loggedPerfMetric.getGaugeMetric().getSessionId()).isEqualTo("sessionId");
assertThat(loggedPerfMetric.getGaugeMetric().getGaugeMetadata().getDeviceRamSizeKb()).isEqualTo(2000);
assertThat(loggedPerfMetric.getGaugeMetric().getGaugeMetadata().getMaxAppJavaHeapMemoryKb()).isEqualTo(1000);
assertThat(loggedPerfMetric.getGaugeMetric().getGaugeMetadata().getMaxEncouragedAppJavaHeapMemoryKb()).isEqualTo(800);
}
use of com.google.firebase.perf.v1.GaugeMetadata in project firebase-android-sdk by firebase.
the class FirebasePerfGaugeManagerValidatorTest method testGaugeMetricWithOnlyGaugeMetadataIsValid.
@Test
public void testGaugeMetricWithOnlyGaugeMetadataIsValid() {
GaugeMetadata gaugeMetadata = createValidGaugeMetadata("processName", /* deviceRamSizeKb= */
2000, /* maxAppJavaHeapMemoryKb= */
1000, /* maxEncouragedAppJavaHeapMemoryKb= */
800);
GaugeMetric.Builder gaugeMetricBuilder = GaugeMetric.newBuilder();
gaugeMetricBuilder.setSessionId("sessionId");
gaugeMetricBuilder.setGaugeMetadata(gaugeMetadata);
FirebasePerfGaugeMetricValidator validator = new FirebasePerfGaugeMetricValidator(gaugeMetricBuilder.build());
assertThat(validator.isValidPerfMetric()).isTrue();
}
Aggregations