Search in sources :

Example 16 with SpanDecorator

use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.

the class JdbcSpanDecoratorTest method testPre.

@Test
public void testPre() {
    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.getBody()).thenReturn(SQL_STATEMENT);
    SpanDecorator decorator = new JdbcSpanDecorator();
    MockTracer tracer = new MockTracer();
    MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
    decorator.pre(span, exchange, endpoint);
    assertEquals("sql", span.tags().get(Tags.DB_TYPE.getKey()));
    assertEquals(SQL_STATEMENT, span.tags().get(Tags.DB_STATEMENT.getKey()));
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) Message(org.apache.camel.Message) SpanDecorator(org.apache.camel.opentracing.SpanDecorator) MockTracer(io.opentracing.mock.MockTracer) MockSpan(io.opentracing.mock.MockSpan) Test(org.junit.Test)

Example 17 with SpanDecorator

use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.

the class MongoDBSpanDecoratorTest method testGetOperationName.

@Test
public void testGetOperationName() {
    Endpoint endpoint = Mockito.mock(Endpoint.class);
    Mockito.when(endpoint.getEndpointUri()).thenReturn(MONGODB_STATEMENT);
    SpanDecorator decorator = new MongoDBSpanDecorator();
    assertEquals("findOneByQuery", decorator.getOperationName(null, endpoint));
}
Also used : Endpoint(org.apache.camel.Endpoint) SpanDecorator(org.apache.camel.opentracing.SpanDecorator) Test(org.junit.Test)

Example 18 with SpanDecorator

use of org.apache.camel.opentracing.SpanDecorator in project camel by apache.

the class SqlSpanDecoratorTest method testPre.

@Test
public void testPre() {
    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(SqlSpanDecorator.CAMEL_SQL_QUERY)).thenReturn(SQL_STATEMENT);
    SpanDecorator decorator = new SqlSpanDecorator();
    MockTracer tracer = new MockTracer();
    MockSpan span = (MockSpan) tracer.buildSpan("TestSpan").start();
    decorator.pre(span, exchange, endpoint);
    assertEquals("sql", span.tags().get(Tags.DB_TYPE.getKey()));
    assertEquals(SQL_STATEMENT, span.tags().get(Tags.DB_STATEMENT.getKey()));
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) Message(org.apache.camel.Message) SpanDecorator(org.apache.camel.opentracing.SpanDecorator) MockTracer(io.opentracing.mock.MockTracer) MockSpan(io.opentracing.mock.MockSpan) Test(org.junit.Test)

Aggregations

SpanDecorator (org.apache.camel.opentracing.SpanDecorator)18 Test (org.junit.Test)18 Endpoint (org.apache.camel.Endpoint)15 MockSpan (io.opentracing.mock.MockSpan)13 MockTracer (io.opentracing.mock.MockTracer)13 Exchange (org.apache.camel.Exchange)11 Message (org.apache.camel.Message)8