use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.
the class AbstractHttpSpanDecoratorTest method testPreUri.
@Test
public void testPreUri() {
Endpoint endpoint = Mockito.mock(Endpoint.class);
Exchange exchange = Mockito.mock(Exchange.class);
Message message = Mockito.mock(Message.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
Mockito.when(exchange.getIn()).thenReturn(message);
Mockito.when(message.getHeader(Exchange.HTTP_URI)).thenReturn(TEST_URI);
SpanDecorator decorator = new AbstractHttpSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
MockTracer tracer = new MockTracer();
MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
decorator.pre(span, exchange, endpoint);
assertEquals(TEST_URI, span.tags().get(Tags.HTTP_URL.getKey()));
assertTrue(span.tags().containsKey(Tags.HTTP_METHOD.getKey()));
}
use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.
the class AbstractMessagingSpanDecoratorTest method testOperationName.
@Test
public void testOperationName() {
Endpoint endpoint = Mockito.mock(Endpoint.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("jms://MyQueue?hello=world");
SpanDecorator decorator = new AbstractMessagingSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
assertEquals("MyQueue", decorator.getOperationName(null, endpoint));
}
use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.
the class AbstractMessagingSpanDecoratorTest method testPreMessageBusDestination.
@Test
public void testPreMessageBusDestination() {
Endpoint endpoint = Mockito.mock(Endpoint.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("jms://MyQueue?hello=world");
SpanDecorator decorator = new AbstractMessagingSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
MockTracer tracer = new MockTracer();
MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
decorator.pre(span, null, endpoint);
assertEquals("MyQueue", span.tags().get(Tags.MESSAGE_BUS_DESTINATION.getKey()));
}
use of org.apache.camel.opentracing.SpanDecorator 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()));
}
use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.
the class AbstractMessagingSpanDecoratorTest method testPreMessageId.
@Test
public void testPreMessageId() {
String messageId = "abcd";
Endpoint endpoint = Mockito.mock(Endpoint.class);
Exchange exchange = Mockito.mock(Exchange.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("test");
SpanDecorator decorator = new AbstractMessagingSpanDecorator() {
@Override
public String getComponent() {
return null;
}
@Override
public String getMessageId(Exchange exchange) {
return messageId;
}
};
MockTracer tracer = new MockTracer();
MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
decorator.pre(span, exchange, endpoint);
assertEquals(messageId, span.tags().get(AwsSqsSpanDecorator.MESSAGE_BUS_ID));
}
Aggregations