Search in sources :

Example 6 with RpcTracing

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
}
Also used : RpcTracing(brave.rpc.RpcTracing) Test(org.junit.Test)

Example 7 with RpcTracing

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
}
Also used : RpcTracing(brave.rpc.RpcTracing) Test(org.junit.Test)

Example 8 with RpcTracing

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
}
Also used : RpcTracing(brave.rpc.RpcTracing) Test(org.junit.Test)

Example 9 with RpcTracing

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
}
Also used : RpcTracing(brave.rpc.RpcTracing) Test(org.junit.Test)

Example 10 with RpcTracing

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);
}
Also used : DubboBootstrap(org.apache.dubbo.config.bootstrap.DubboBootstrap) RpcResponseParser(brave.rpc.RpcResponseParser) RpcContext(org.apache.dubbo.rpc.RpcContext) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ALWAYS_SAMPLE(brave.sampler.Sampler.ALWAYS_SAMPLE) Test(org.junit.Test) TraceContext(brave.propagation.TraceContext) Result(org.apache.dubbo.rpc.Result) RpcTracing(brave.rpc.RpcTracing) B3SingleFormat(brave.propagation.B3SingleFormat) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) MutableSpan(brave.handler.MutableSpan) RpcRuleSampler(brave.rpc.RpcRuleSampler) NEVER_SAMPLE(brave.sampler.Sampler.NEVER_SAMPLE) ReferenceConfig(org.apache.dubbo.config.ReferenceConfig) Tag(brave.Tag) SamplingFlags(brave.propagation.SamplingFlags) SERVER(brave.Span.Kind.SERVER) RpcRequestMatchers.methodEquals(brave.rpc.RpcRequestMatchers.methodEquals) RpcRequestMatchers.serviceEquals(brave.rpc.RpcRequestMatchers.serviceEquals) Before(org.junit.Before) TraceContext(brave.propagation.TraceContext) RpcTracing(brave.rpc.RpcTracing) Tag(brave.Tag) Result(org.apache.dubbo.rpc.Result) Test(org.junit.Test)

Aggregations

RpcTracing (brave.rpc.RpcTracing)10 Test (org.junit.Test)10 Tag (brave.Tag)4 SamplingFlags (brave.propagation.SamplingFlags)4 TraceContext (brave.propagation.TraceContext)4 RpcRequestMatchers.methodEquals (brave.rpc.RpcRequestMatchers.methodEquals)4 RpcRequestMatchers.serviceEquals (brave.rpc.RpcRequestMatchers.serviceEquals)4 RpcResponseParser (brave.rpc.RpcResponseParser)4 RpcRuleSampler (brave.rpc.RpcRuleSampler)4 ALWAYS_SAMPLE (brave.sampler.Sampler.ALWAYS_SAMPLE)4 NEVER_SAMPLE (brave.sampler.Sampler.NEVER_SAMPLE)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)4 Before (org.junit.Before)4 MutableSpan (brave.handler.MutableSpan)3 Clock (brave.Clock)2 CLIENT (brave.Span.Kind.CLIENT)2 SERVER (brave.Span.Kind.SERVER)2 B3SingleFormat (brave.propagation.B3SingleFormat)2 Scope (brave.propagation.CurrentTraceContext.Scope)2