use of io.opentracing.mock.MockTracer in project wildfly by wildfly.
the class ResourceTracedTestCase method tracedEndpointYieldsSpan.
@Test
public void tracedEndpointYieldsSpan() throws Exception {
Assert.assertTrue(tracer instanceof MockTracer);
MockTracer mockTracer = (MockTracer) tracer;
performCall("opentracing/traced");
Assert.assertEquals(1, mockTracer.finishedSpans().size());
// Expected trace if the http-path configuration is not set
Assert.assertNotEquals("GET:org.wildfly.test.integration.microprofile.opentracing.application.TracedEndpoint.get", mockTracer.finishedSpans().get(0).operationName());
Assert.assertEquals("GET:/traced/", mockTracer.finishedSpans().get(0).operationName());
Assert.assertEquals((servletContext.getContextPath() + ".war").substring(1), servletContext.getAttribute("smallrye.opentracing.serviceName"));
}
use of io.opentracing.mock.MockTracer in project wildfly by wildfly.
the class ResourceWithCustomOperationNameNoTopicSetupOverrideForAllMessagesTestCase method customOperationName.
@Test
public void customOperationName() throws Exception {
Assert.assertTrue(tracer instanceof MockTracer);
MockTracer mockTracer = (MockTracer) tracer;
performCall("opentracing/with-custom-operation-name");
List<MockSpan> spans = mockTracer.finishedSpans();
IntStream.range(0, spans.size()).forEach(idx -> System.out.println("*** " + idx + ": " + spans.get(idx).toString()));
Assert.assertEquals(3, spans.size());
Assert.assertEquals("my-custom-method-operation-name", spans.get(0).operationName());
Assert.assertEquals("my-custom-class-operation-name", spans.get(1).operationName());
String opName = spans.get(2).operationName();
Assert.assertTrue(opName, opName.contains(WithCustomOperationNameEndpoint.class.getName()));
}
use of io.opentracing.mock.MockTracer in project camel by apache.
the class CamelOpenTracingTestSupport method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext context = super.createCamelContext();
tracer = new MockTracer(Propagator.TEXT_MAP);
OpenTracingTracer ottracer = new OpenTracingTracer();
ottracer.setTracer(tracer);
ottracer.init(context);
return context;
}
use of io.opentracing.mock.MockTracer in project camel by apache.
the class SpringOpenTracingSimpleRouteTest method testRoute.
@Test
public void testRoute() throws Exception {
NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();
for (int i = 0; i < 5; i++) {
template.sendBody("seda:dude", "Hello World");
}
assertTrue(notify.matches(30, TimeUnit.SECONDS));
MockTracer tracer = (MockTracer) context().getRegistry().lookupByName("mockTracer");
// Four spans per invocation, one for client, two for dude route (server and client to), one for car route
assertEquals(20, tracer.finishedSpans().size());
}
use of io.opentracing.mock.MockTracer in project camel by apache.
the class AbstractHttpSpanDecoratorTest method testPostResponseCode.
@Test
public void testPostResponseCode() {
Exchange exchange = Mockito.mock(Exchange.class);
Message message = Mockito.mock(Message.class);
Mockito.when(exchange.hasOut()).thenReturn(true);
Mockito.when(exchange.getOut()).thenReturn(message);
Mockito.when(message.getHeader(Exchange.HTTP_RESPONSE_CODE)).thenReturn(200);
SpanDecorator decorator = new AbstractHttpSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
MockTracer tracer = new MockTracer();
MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
decorator.post(span, exchange, null);
assertEquals(200, span.tags().get(Tags.HTTP_STATUS.getKey()));
}
Aggregations