use of brave.rpc.RpcTracing in project brave by openzipkin.
the class BaseITTracingClientInterceptor method customSampler.
/* RpcTracing-specific feature tests */
@Test
public void customSampler() {
closeClient(client);
RpcTracing rpcTracing = RpcTracing.newBuilder(tracing).clientSampler(RpcRuleSampler.newBuilder().putRule(methodEquals("SayHelloWithManyReplies"), NEVER_SAMPLE).putRule(serviceEquals("helloworld.greeter"), ALWAYS_SAMPLE).build()).build();
grpcTracing = GrpcTracing.create(rpcTracing);
client = newClient();
// unsampled
// NOTE: An iterator request is lazy: invoking the iterator invokes the request
GreeterGrpc.newBlockingStub(client).sayHelloWithManyReplies(HELLO_REQUEST).hasNext();
// sampled
GreeterGrpc.newBlockingStub(client).sayHello(HELLO_REQUEST);
assertThat(testSpanHandler.takeRemoteSpan(CLIENT).name()).isEqualTo("helloworld.Greeter/SayHello");
// @After will also check that sayHelloWithManyReplies was not sampled
}
use of brave.rpc.RpcTracing in project brave by openzipkin.
the class ITTracingFilter_Consumer method customSampler.
/* RpcTracing-specific feature tests */
@Test
public void customSampler() {
RpcTracing rpcTracing = RpcTracing.newBuilder(tracing).clientSampler(RpcRuleSampler.newBuilder().putRule(methodEquals("sayGoodbye"), NEVER_SAMPLE).putRule(serviceEquals("brave.dubbo"), ALWAYS_SAMPLE).build()).build();
init().setRpcTracing(rpcTracing);
// unsampled
client.get().sayGoodbye("jorge");
// sampled
client.get().sayHello("jorge");
assertThat(testSpanHandler.takeRemoteSpan(CLIENT).name()).endsWith("sayHello");
// @After will also check that sayGoodbye was not sampled
}
use of brave.rpc.RpcTracing in project brave by openzipkin.
the class ITTracingFilter_Provider method customSampler.
/* RpcTracing-specific feature tests */
@Test
public void customSampler() {
RpcTracing rpcTracing = RpcTracing.newBuilder(tracing).serverSampler(RpcRuleSampler.newBuilder().putRule(methodEquals("sayGoodbye"), NEVER_SAMPLE).putRule(serviceEquals("brave.dubbo"), ALWAYS_SAMPLE).build()).build();
init().setRpcTracing(rpcTracing);
// unsampled
client.get().sayGoodbye("jorge");
// sampled
client.get().sayHello("jorge");
assertThat(testSpanHandler.takeRemoteSpan(SERVER).name()).endsWith("sayHello");
// @After will also check that sayGoodbye was not sampled
}
use of brave.rpc.RpcTracing in project brave by openzipkin.
the class ITTracingFilter_Consumer method customSampler.
/* RpcTracing-specific feature tests */
@Test
public void customSampler() {
RpcTracing rpcTracing = RpcTracing.newBuilder(tracing).clientSampler(RpcRuleSampler.newBuilder().putRule(methodEquals("sayGoodbye"), NEVER_SAMPLE).putRule(serviceEquals("brave.dubbo"), ALWAYS_SAMPLE).build()).build();
init().setRpcTracing(rpcTracing);
// unsampled
client.get().sayGoodbye("jorge");
// sampled
client.get().sayHello("jorge");
assertThat(testSpanHandler.takeRemoteSpan(CLIENT).name()).endsWith("sayHello");
// @After will also check that sayGoodbye was not sampled
}
use of brave.rpc.RpcTracing in project brave by openzipkin.
the class ITTracingFilter_Provider method customParser.
@Test
public void customParser() {
Tag<DubboResponse> javaValue = new Tag<DubboResponse>("dubbo.result_value") {
@Override
protected String parseValue(DubboResponse input, TraceContext context) {
Result result = input.result();
if (result == null)
return null;
return String.valueOf(result.getValue());
}
};
RpcTracing rpcTracing = RpcTracing.newBuilder(tracing).serverResponseParser((res, context, span) -> {
RpcResponseParser.DEFAULT.parse(res, context, span);
if (res instanceof DubboResponse) {
javaValue.tag((DubboResponse) res, span);
}
}).build();
init().setRpcTracing(rpcTracing);
String javaResult = client.get().sayHello("jorge");
assertThat(testSpanHandler.takeRemoteSpan(SERVER).tags()).containsEntry("dubbo.result_value", javaResult);
}
Aggregations