use of io.grpc.examples.helloworld.HelloReply in project brave by openzipkin.
the class ITTracingClientInterceptor method addsErrorTag_onCanceledFuture.
@Test
public void addsErrorTag_onCanceledFuture() throws Exception {
server.enqueueDelay(TimeUnit.SECONDS.toMillis(1));
ListenableFuture<HelloReply> resp = GreeterGrpc.newFutureStub(client).sayHello(HELLO_REQUEST);
assumeTrue("lost race on cancel", resp.cancel(true));
Span span = spans.take();
assertThat(span.tags()).containsExactly(entry("error", "CANCELLED"), entry("grpc.status_code", "CANCELLED"));
}
use of io.grpc.examples.helloworld.HelloReply in project brave by openzipkin.
the class ITTracingServerInterceptor method serverParserTestWithStreamingResponse.
@Test
public void serverParserTestWithStreamingResponse() throws Exception {
grpcTracing = grpcTracing.toBuilder().serverParser(new GrpcServerParser() {
int responsesSent = 0;
@Override
protected <M> void onMessageSent(M message, SpanCustomizer span) {
span.tag("grpc.message_sent." + responsesSent++, message.toString());
}
}).build();
init();
Iterator<HelloReply> replies = GreeterGrpc.newBlockingStub(client).sayHelloWithManyReplies(HELLO_REQUEST);
assertThat(replies).hasSize(10);
// all response messages are tagged to the same span
Span span = spans.take();
assertThat(span.tags()).hasSize(10);
}
use of io.grpc.examples.helloworld.HelloReply in project pinpoint by naver.
the class HelloWorldSimpleClient method greet.
public String greet(String name) {
HelloRequest request = HelloRequest.newBuilder().setName(name).build();
HelloReply response = blockingStub.sayHello(request);
logger.info("Greeting: {}" + response.getMessage());
return response.getMessage();
}
use of io.grpc.examples.helloworld.HelloReply in project grpc-java by grpc.
the class SafeMethodCachingInterceptorTest method invalidResponseMaxAge_usesDefault.
@Test
public void invalidResponseMaxAge_usesDefault() throws Exception {
SafeMethodCachingInterceptor interceptorWithCustomMaxAge = SafeMethodCachingInterceptor.newSafeMethodCachingInterceptor(cache, 1);
channelToUse = ClientInterceptors.intercept(baseChannel, interceptorWithCustomMaxAge);
cacheControlDirectives.add("max-age=-10");
HelloReply reply1 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
HelloReply reply2 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
assertEquals(reply1, reply2);
// Wait for cache entry to expire
sleepAtLeast(1001);
assertNotEquals(reply1, ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message));
Truth.assertThat(cache.removedKeys).hasSize(1);
assertEquals(new SafeMethodCachingInterceptor.Key(GreeterGrpc.getSayHelloMethod().getFullMethodName(), message), cache.removedKeys.get(0));
}
use of io.grpc.examples.helloworld.HelloReply in project grpc-java by grpc.
the class SafeMethodCachingInterceptorTest method afterDefaultMaxAge_cacheEntryInvalidated.
@Test
public void afterDefaultMaxAge_cacheEntryInvalidated() throws Exception {
SafeMethodCachingInterceptor interceptorWithCustomMaxAge = SafeMethodCachingInterceptor.newSafeMethodCachingInterceptor(cache, 1);
channelToUse = ClientInterceptors.intercept(baseChannel, interceptorWithCustomMaxAge);
HelloReply reply1 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
HelloReply reply2 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
assertSame(reply1, reply2);
// Wait for cache entry to expire
sleepAtLeast(1001);
assertNotEquals(reply1, ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message));
Truth.assertThat(cache.removedKeys).hasSize(1);
assertEquals(new SafeMethodCachingInterceptor.Key(GreeterGrpc.getSayHelloMethod().getFullMethodName(), message), cache.removedKeys.get(0));
}
Aggregations