use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class HttpMetricTest method putAttributeAfterHttpMetricIsStopped.
@Test
public void putAttributeAfterHttpMetricIsStopped() {
HttpMetric metric = new HttpMetric("https://www.google.com/", HttpMethod.GET, transportManager, timer);
metric.start();
metric.stop();
metric.putAttribute("attr1", "free");
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.nullable(ApplicationProcessState.class));
NetworkRequestMetric metricValue = networkArgumentCaptor.getValue();
assertThat(metricValue.getUrl()).isEqualTo("https://www.google.com/");
assertThat(metricValue.getHttpMethod()).isEqualTo(com.google.firebase.perf.v1.NetworkRequestMetric.HttpMethod.GET);
assertThat(metricValue.getClientStartTimeUs()).isEqualTo(1000);
assertThat(metricValue.getTimeToResponseCompletedUs()).isEqualTo(2000);
assertThat(metricValue.getCustomAttributesCount()).isEqualTo(0);
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class HttpMetricTest method testMaxAttributes.
@Test
public void testMaxAttributes() {
HttpMetric metric = new HttpMetric("https://www.google.com/", HttpMethod.GET, transportManager, timer);
metric.start();
for (int i = 0; i <= Constants.MAX_TRACE_CUSTOM_ATTRIBUTES; i++) {
metric.putAttribute("dim" + i, "value" + i);
}
for (int i = 0; i <= Constants.MAX_TRACE_CUSTOM_ATTRIBUTES; i++) {
metric.putAttribute("dim" + i, "value" + (i + 1));
}
metric.stop();
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.nullable(ApplicationProcessState.class));
NetworkRequestMetric metricValue = networkArgumentCaptor.getValue();
assertThat(metricValue.getUrl()).isEqualTo("https://www.google.com/");
assertThat(metricValue.getHttpMethod()).isEqualTo(com.google.firebase.perf.v1.NetworkRequestMetric.HttpMethod.GET);
assertThat(metricValue.getClientStartTimeUs()).isEqualTo(1000);
assertThat(metricValue.getTimeToResponseCompletedUs()).isEqualTo(2000);
assertThat(metricValue.getCustomAttributesCount()).isEqualTo(Constants.MAX_TRACE_CUSTOM_ATTRIBUTES);
for (int i = 0; i < Constants.MAX_TRACE_CUSTOM_ATTRIBUTES; i++) {
String attributeValue = "value" + (i + 1);
String attributeKey = "dim" + i;
assertThat(metric.getAttribute(attributeKey)).isEqualTo(attributeValue);
}
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class HttpMetricTest method setResponseContentType.
@Test
public void setResponseContentType() {
HttpMetric metric = new HttpMetric("https://www.google.com/", HttpMethod.GET, transportManager, timer);
metric.start();
metric.setResponseContentType("text/html");
metric.stop();
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.nullable(ApplicationProcessState.class));
NetworkRequestMetric metricValue = networkArgumentCaptor.getValue();
verifyMetric(metricValue);
assertThat(metricValue.getResponseContentType()).isEqualTo("text/html");
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class NetworkRequestMetricBuilderTest method testSetRequestPayloadBytes.
@Test
public void testSetRequestPayloadBytes() {
long bytes = 256;
NetworkRequestMetric metric = networkMetricBuilder.setRequestPayloadBytes(bytes).build();
assertThat(metric.getRequestPayloadBytes()).isEqualTo(bytes);
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class NetworkRequestMetricBuilderTest method testSetResponseContentType.
@Test
public void testSetResponseContentType() {
String contentType = "text/html";
NetworkRequestMetric metric = networkMetricBuilder.setResponseContentType(contentType).build();
assertThat(metric.getResponseContentType()).isEqualTo(contentType);
}
Aggregations