RpcServerHandler extends RpcHandler<RpcServerRequest, RpcServerResponse> { public Span handleReceive(RpcServerRequest request) { Span span = nextSpan(extractor.extract(request), request); return handleStart(request, span); } RpcServerHandler(RpcTracing rpcTracing); static RpcServerHandler create(RpcTracing rpcTracing); Span handleReceive(RpcServerRequest request); void handleSend(RpcServerResponse response, Span span);  }
@Test public void handleReceive_traceIdSamplerSpecialCased() { Sampler sampler = mock(Sampler.class); init(httpTracingBuilder(tracingBuilder().sampler(sampler)) .serverSampler(SamplerFunctions.deferDecision())); assertThat(handler.handleReceive(request).isNoop()).isTrue(); verify(sampler).isSampled(anyLong()); }
@Test public void handleReceive_neverSamplerSpecialCased() { Sampler sampler = mock(Sampler.class); init(httpTracingBuilder(tracingBuilder().sampler(sampler)) .serverSampler(SamplerFunctions.neverSample())); assertThat(handler.handleReceive(request).isNoop()).isTrue(); verifyNoMoreInteractions(sampler); }
@Test public void handleReceive_samplerSeesRpcServerRequest() { SamplerFunction<RpcRequest> serverSampler = mock(SamplerFunction.class); init(httpTracingBuilder(tracingBuilder()).serverSampler(serverSampler)); handler.handleReceive(request); verify(serverSampler).trySample(request); }