use of io.grpc.internal.testing.StatsTestUtils.MetricsRecord in project grpc-java by grpc.
the class RetryTest method assertOutboundWireSizeRecorded.
private void assertOutboundWireSizeRecorded(long length) throws Exception {
MetricsRecord record = clientStatsRecorder.pollRecord(5, SECONDS);
assertThat(record.getMetricAsLongOrFail(RpcMeasureConstants.GRPC_CLIENT_SENT_BYTES_PER_METHOD)).isEqualTo(length);
}
use of io.grpc.internal.testing.StatsTestUtils.MetricsRecord in project grpc-java by grpc.
the class RetryTest method assertInboundWireSizeRecorded.
private void assertInboundWireSizeRecorded(long length) throws Exception {
MetricsRecord record = clientStatsRecorder.pollRecord(5, SECONDS);
assertThat(record.getMetricAsLongOrFail(RpcMeasureConstants.GRPC_CLIENT_RECEIVED_BYTES_PER_METHOD)).isEqualTo(length);
}
use of io.grpc.internal.testing.StatsTestUtils.MetricsRecord in project grpc-java by grpc.
the class AbstractInteropTest method deadlineExceededServerStreaming.
@Test
public void deadlineExceededServerStreaming() throws Exception {
// warm up the channel and JVM
blockingStub.emptyCall(Empty.getDefaultInstance());
assertStatsTrace("grpc.testing.TestService/EmptyCall", Status.Code.OK);
ResponseParameters.Builder responseParameters = ResponseParameters.newBuilder().setSize(1).setIntervalUs(10000);
StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder().addResponseParameters(responseParameters).addResponseParameters(responseParameters).addResponseParameters(responseParameters).addResponseParameters(responseParameters).build();
StreamRecorder<StreamingOutputCallResponse> recorder = StreamRecorder.create();
asyncStub.withDeadlineAfter(30, TimeUnit.MILLISECONDS).streamingOutputCall(request, recorder);
recorder.awaitCompletion();
assertEquals(Status.DEADLINE_EXCEEDED.getCode(), Status.fromThrowable(recorder.getError()).getCode());
if (metricsExpected()) {
// Stream may not have been created when deadline is exceeded, thus we don't check tracer
// stats.
MetricsRecord clientStartRecord = clientStatsRecorder.pollRecord(5, TimeUnit.SECONDS);
checkStartTags(clientStartRecord, "grpc.testing.TestService/StreamingOutputCall", true);
MetricsRecord clientEndRecord = clientStatsRecorder.pollRecord(5, TimeUnit.SECONDS);
checkEndTags(clientEndRecord, "grpc.testing.TestService/StreamingOutputCall", Status.Code.DEADLINE_EXCEEDED, true);
// Do not check server-side metrics, because the status on the server side is undetermined.
}
}
use of io.grpc.internal.testing.StatsTestUtils.MetricsRecord in project grpc-java by grpc.
the class AbstractInteropTest method assertClientStatsTrace.
private void assertClientStatsTrace(String method, Status.Code code, Collection<? extends MessageLite> requests, Collection<? extends MessageLite> responses) {
// Tracer-based stats
TestClientStreamTracer tracer = clientStreamTracers.poll();
assertNotNull(tracer);
assertTrue(tracer.getOutboundHeaders());
// but streamClosed() may be called slightly later than that. So we need a timeout.
try {
assertTrue(tracer.await(5, TimeUnit.SECONDS));
} catch (InterruptedException e) {
throw new AssertionError(e);
}
assertEquals(code, tracer.getStatus().getCode());
if (requests != null && responses != null) {
checkTracers(tracer, requests, responses);
}
if (metricsExpected()) {
// CensusStreamTracerModule records final status in interceptor, which is guaranteed to be
// done before application receives status.
MetricsRecord clientStartRecord = clientStatsRecorder.pollRecord();
checkStartTags(clientStartRecord, method, true);
MetricsRecord clientEndRecord = clientStatsRecorder.pollRecord();
checkEndTags(clientEndRecord, method, code, true);
if (requests != null && responses != null) {
checkCensus(clientEndRecord, false, requests, responses);
}
assertZeroRetryRecorded();
}
}
Aggregations