use of brave.ScopedSpan in project brave by openzipkin.
the class ITTracingStatementInterceptor method makesChildOfCurrentSpan.
@Test
public void makesChildOfCurrentSpan() throws Exception {
ScopedSpan parent = tracing.tracer().startScopedSpan("test");
try {
prepareExecuteSelect(QUERY);
} finally {
parent.finish();
}
assertThat(spans).hasSize(2);
}
use of brave.ScopedSpan in project brave by openzipkin.
the class ITTracingP6Factory method makesChildOfCurrentSpan.
@Test
public void makesChildOfCurrentSpan() throws Exception {
ScopedSpan parent = tracing.tracer().startScopedSpan("test");
try {
prepareExecuteSelect(QUERY);
} finally {
parent.finish();
}
assertThat(spans).hasSize(2);
}
use of brave.ScopedSpan in project cxf by apache.
the class CatalogServiceImpl method addBook.
public void addBook(Book book) {
final TraceContext parent = brave.tracer().currentSpan().context();
executor.submit(() -> {
final ScopedSpan span = brave.tracer().startScopedSpanWithParent("Inserting New Book", parent);
try {
books.put(book.getId(), book);
} finally {
span.finish();
}
});
}
use of brave.ScopedSpan in project brave by openzipkin.
the class BaseITTracingClientInterceptor method messageTagging_unary.
/**
* This shows that a {@link ClientInterceptor} can see the server server span when processing the
* request and response.
*/
@Test
public void messageTagging_unary() {
initMessageTaggingClient();
ScopedSpan span = tracing.tracer().startScopedSpan("parent");
try {
GreeterGrpc.newBlockingStub(client).sayHello(HELLO_REQUEST);
} finally {
span.finish();
}
assertThat(testSpanHandler.takeRemoteSpan(CLIENT).tags()).containsKey("grpc.message_send.1");
// Response processing happens on the invocation (parent) trace context
assertThat(testSpanHandler.takeLocalSpan().tags()).containsKey("grpc.message_recv.1");
}
use of brave.ScopedSpan in project brave by openzipkin.
the class BaseITTracingClientInterceptor method clientParserTest.
@Test
public void clientParserTest() {
closeClient(client);
grpcTracing = grpcTracing.toBuilder().clientParser(new GrpcClientParser() {
@Override
protected <M> void onMessageSent(M message, SpanCustomizer span) {
span.tag("grpc.message_sent", message.toString());
if (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.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();
ScopedSpan parent = tracing.tracer().startScopedSpan("parent");
try {
GreeterGrpc.newBlockingStub(client).sayHello(HELLO_REQUEST);
} finally {
parent.finish();
}
MutableSpan span = testSpanHandler.takeRemoteSpan(CLIENT);
assertThat(span.name()).isEqualTo("UNARY");
assertThat(span.tags()).containsKeys("grpc.message_received", "grpc.message_sent", "grpc.message_received.visible", "grpc.message_sent.visible");
testSpanHandler.takeLocalSpan();
}
Aggregations