use of io.opencensus.proto.trace.v1.Span in project brave by openzipkin.
the class ITTracingFilter_Consumer method onTransportException_addsErrorTag_async.
@Test
public void onTransportException_addsErrorTag_async() throws Exception {
server.stop();
RpcContext.getContext().asyncCall(() -> client.get().sayHello("romeo"));
Span span = spans.take();
assertThat(span.tags().get("error")).contains("RemotingException");
}
use of io.opencensus.proto.trace.v1.Span in project brave by openzipkin.
the class ITTracingFilter_Provider method usesExistingTraceId.
@Test
public void usesExistingTraceId() throws Exception {
final String traceId = "463ac35c9f6413ad";
final String parentId = traceId;
final String spanId = "48485a3953bb6124";
RpcContext.getContext().getAttachments().put("X-B3-TraceId", traceId);
RpcContext.getContext().getAttachments().put("X-B3-ParentSpanId", parentId);
RpcContext.getContext().getAttachments().put("X-B3-SpanId", spanId);
RpcContext.getContext().getAttachments().put("X-B3-Sampled", "1");
client.get().sayHello("jorge");
Span span = spans.take();
assertThat(span.traceId()).isEqualTo(traceId);
assertThat(span.parentId()).isEqualTo(parentId);
assertThat(span.id()).isEqualTo(spanId);
assertThat(span.shared()).isTrue();
}
use of io.opencensus.proto.trace.v1.Span in project brave by openzipkin.
the class ITTracingFilter_Provider method defaultSpanNameIsMethodName.
@Test
public void defaultSpanNameIsMethodName() throws Exception {
client.get().sayHello("jorge");
Span span = spans.take();
assertThat(span.name()).isEqualTo("genericservice/sayhello");
}
use of io.opencensus.proto.trace.v1.Span in project brave by openzipkin.
the class ITTracingClientInterceptor method clientParserTest.
@Test
public void clientParserTest() throws Exception {
closeClient(client);
tracing = tracing.toBuilder().clientParser(new GrpcClientParser() {
@Override
protected <M> void onMessageSent(M message, SpanCustomizer span) {
span.tag("grpc.message_sent", message.toString());
if (tracing.tracing().currentTraceContext().get() != null) {
span.tag("grpc.message_sent.visible", "true");
}
}
@Override
protected <M> void onMessageReceived(M message, SpanCustomizer span) {
span.tag("grpc.message_received", message.toString());
if (tracing.tracing().currentTraceContext().get() != null) {
span.tag("grpc.message_received.visible", "true");
}
}
@Override
protected <ReqT, RespT> String spanName(MethodDescriptor<ReqT, RespT> methodDescriptor) {
return methodDescriptor.getType().name();
}
}).build();
client = newClient();
GreeterGrpc.newBlockingStub(client).sayHello(HELLO_REQUEST);
Span span = spans.take();
assertThat(span.name()).isEqualTo("unary");
assertThat(span.tags()).containsKeys("grpc.message_received", "grpc.message_sent", "grpc.message_received.visible", "grpc.message_sent.visible");
}
use of io.opencensus.proto.trace.v1.Span in project brave by openzipkin.
the class ITTracingClientInterceptor method defaultSpanNameIsMethodName.
@Test
public void defaultSpanNameIsMethodName() throws Exception {
GreeterGrpc.newBlockingStub(client).sayHello(HELLO_REQUEST);
Span span = spans.take();
assertThat(span.name()).isEqualTo("helloworld.greeter/sayhello");
}
Aggregations