use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.
the class TimerSpanDecoratorTest method testGetOperationName.
@Test
public void testGetOperationName() {
Exchange exchange = Mockito.mock(Exchange.class);
Mockito.when(exchange.getProperty(Exchange.TIMER_NAME)).thenReturn(TEST_NAME);
SpanDecorator decorator = new TimerSpanDecorator() {
@Override
public String getComponent() {
return null;
}
};
assertEquals(TEST_NAME, decorator.getOperationName(exchange, null));
}
use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.
the class CqlSpanDecoratorTest method testPreCqlFromHeader.
@Test
public void testPreCqlFromHeader() {
String cql = "select * from users";
Endpoint endpoint = Mockito.mock(Endpoint.class);
Exchange exchange = Mockito.mock(Exchange.class);
Message message = Mockito.mock(Message.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("cql://host1,host2?consistencyLevel=quorum");
Mockito.when(exchange.getIn()).thenReturn(message);
Mockito.when(message.getHeader(CqlSpanDecorator.CAMEL_CQL_QUERY)).thenReturn(cql);
SpanDecorator decorator = new CqlSpanDecorator();
MockTracer tracer = new MockTracer();
MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
decorator.pre(span, exchange, endpoint);
assertEquals(CqlSpanDecorator.CASSANDRA_DB_TYPE, span.tags().get(Tags.DB_TYPE.getKey()));
assertEquals(cql, span.tags().get(Tags.DB_STATEMENT.getKey()));
assertNull(span.tags().get(Tags.DB_INSTANCE.getKey()));
}
use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.
the class ElasticsearchSpanDecoratorTest method testOperationName.
@Test
public void testOperationName() {
String opName = "INDEX";
Endpoint endpoint = Mockito.mock(Endpoint.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("elasticsearch://local?operation=" + opName + "&indexName=twitter&indexType=tweet");
SpanDecorator decorator = new ElasticsearchSpanDecorator();
assertEquals(opName, decorator.getOperationName(null, endpoint));
}
use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.
the class KafkaSpanDecoratorTest method testPre.
@Test
public void testPre() {
String testKey = "TestKey";
String testOffset = "TestOffset";
String testPartition = "TestPartition";
String testPartitionKey = "TestPartitionKey";
Endpoint endpoint = Mockito.mock(Endpoint.class);
Exchange exchange = Mockito.mock(Exchange.class);
Message message = Mockito.mock(Message.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn("test");
Mockito.when(exchange.getIn()).thenReturn(message);
Mockito.when(message.getHeader(KafkaSpanDecorator.KEY)).thenReturn(testKey);
Mockito.when(message.getHeader(KafkaSpanDecorator.OFFSET)).thenReturn(testOffset);
Mockito.when(message.getHeader(KafkaSpanDecorator.PARTITION)).thenReturn(testPartition);
Mockito.when(message.getHeader(KafkaSpanDecorator.PARTITION_KEY)).thenReturn(testPartitionKey);
SpanDecorator decorator = new KafkaSpanDecorator();
MockTracer tracer = new MockTracer();
MockSpan span = tracer.buildSpan("TestSpan").start();
decorator.pre(span, exchange, endpoint);
assertEquals(testKey, span.tags().get(KafkaSpanDecorator.KAFKA_KEY_TAG));
assertEquals(testOffset, span.tags().get(KafkaSpanDecorator.KAFKA_OFFSET_TAG));
assertEquals(testPartition, span.tags().get(KafkaSpanDecorator.KAFKA_PARTITION_TAG));
assertEquals(testPartitionKey, span.tags().get(KafkaSpanDecorator.KAFKA_PARTITION_KEY_TAG));
}
use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.
the class MongoDBSpanDecoratorTest method testPre.
@Test
public void testPre() {
Endpoint endpoint = Mockito.mock(Endpoint.class);
Mockito.when(endpoint.getEndpointUri()).thenReturn(MONGODB_STATEMENT);
SpanDecorator decorator = new MongoDBSpanDecorator();
MockTracer tracer = new MockTracer();
MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
decorator.pre(span, null, endpoint);
assertEquals("mongodb", span.tags().get(Tags.DB_TYPE.getKey()));
assertEquals("flights", span.tags().get(Tags.DB_INSTANCE.getKey()));
assertTrue(span.tags().containsKey(Tags.DB_STATEMENT.getKey()));
}
Aggregations