RpcClientHandler extends RpcHandler<RpcClientRequest, RpcClientResponse> { public Span handleSend(RpcClientRequest request) { if (request == null) throw new NullPointerException("request == null"); return handleSend(request, tracer.nextSpan(sampler, request)); } RpcClientHandler(RpcTracing rpcTracing); static RpcClientHandler create(RpcTracing rpcTracing); Span handleSend(RpcClientRequest request); Span handleSendWithParent(RpcClientRequest request, @Nullable TraceContext parent); Span handleSend(RpcClientRequest request, Span span); void handleReceive(RpcClientResponse response, Span span);  }
@Test public void handleSend_traceIdSamplerSpecialCased() { Sampler sampler = mock(Sampler.class); init(httpTracingBuilder(tracingBuilder().sampler(sampler)) .clientSampler(SamplerFunctions.deferDecision())); assertThat(handler.handleSend(request).isNoop()).isTrue(); verify(sampler).isSampled(anyLong()); }
@Test public void handleSend_neverSamplerSpecialCased() { Sampler sampler = mock(Sampler.class); init(httpTracingBuilder(tracingBuilder().sampler(sampler)) .clientSampler(SamplerFunctions.neverSample())); assertThat(handler.handleSend(request).isNoop()).isTrue(); verifyNoMoreInteractions(sampler); }
@Test public void handleSend_samplerSeesRpcClientRequest() { SamplerFunction<RpcRequest> clientSampler = mock(SamplerFunction.class); init(httpTracingBuilder(tracingBuilder()).clientSampler(clientSampler)); handler.handleSend(request); verify(clientSampler).trySample(request); }