use of io.opentracing.mock.MockTracer in project ballerina by ballerina-lang.
the class BMockTracer method getTracer.
@Override
public Tracer getTracer(String tracerName, Properties configProperties, String serviceName) throws InvalidConfigurationException {
MockTracer mockTracer = new MockTracer();
BMockTracer.tracerMap.add(mockTracer);
return mockTracer;
}
use of io.opentracing.mock.MockTracer in project motan by weibocom.
the class OpenTracingFilterTest method checkMockTracer.
private void checkMockTracer() {
if (tracer instanceof MockTracer) {
MockTracer mt = (MockTracer) tracer;
assertEquals(1, mt.finishedSpans().size());
MockSpan span = mt.finishedSpans().get(0);
assertEquals(span.operationName(), "Motan_test_HelloService.sayHello(java.lang.String)");
assertEquals(span.parentId(), 0);
assertEquals(span.logEntries().size(), 1);
assertTrue("request success.".equals(span.logEntries().get(0).fields().get("event")));
assertTrue(span.tags().containsKey("requestId"));
}
}
use of io.opentracing.mock.MockTracer in project wildfly by wildfly.
the class ResourceNotTracedTestCase method notTracedEndpointYieldsNoSpans.
@Test
public void notTracedEndpointYieldsNoSpans() throws Exception {
Assert.assertTrue(tracer instanceof MockTracer);
MockTracer mockTracer = (MockTracer) tracer;
performCall("opentracing/not-traced");
Assert.assertEquals(0, mockTracer.finishedSpans().size());
}
use of io.opentracing.mock.MockTracer in project wildfly by wildfly.
the class ResourceWithCDITestCase method tracedEndpointYieldsSpan.
@Test
public void tracedEndpointYieldsSpan() throws Exception {
Assert.assertTrue(tracer instanceof MockTracer);
MockTracer mockTracer = (MockTracer) tracer;
performCall("opentracing/with-bean");
Assert.assertEquals(3, mockTracer.finishedSpans().size());
}
use of io.opentracing.mock.MockTracer in project wildfly by wildfly.
the class SimpleRestClientTestCase method clientRequestSpanJoinsServer.
@Test
public void clientRequestSpanJoinsServer() {
// sanity checks
Assert.assertNotNull(tracer);
Assert.assertTrue(tracer instanceof MockTracer);
// the first span
try (Scope ignored = tracer.activateSpan(tracer.buildSpan("existing-span").start())) {
// the second span is the client request, as a child of `existing-span`
Client restClient = ClientTracingRegistrar.configure(ClientBuilder.newBuilder()).build();
// the third span is the traced endpoint, child of the client request
String targetUrl = url.toString() + "opentracing/traced";
System.out.println("We are trying to open " + targetUrl);
WebTarget target = restClient.target(targetUrl);
try (Response response = target.request().get()) {
// just a sanity check
Assert.assertEquals(200, response.getStatus());
}
tracer.activeSpan().finish();
}
// verify
MockTracer mockTracer = (MockTracer) tracer;
List<MockSpan> spans = mockTracer.finishedSpans();
Assert.assertEquals(3, spans.size());
long traceId = spans.get(0).context().traceId();
for (MockSpan span : spans) {
// they should all belong to the same trace
Assert.assertEquals(traceId, span.context().traceId());
}
}
Aggregations