Search in sources :

Example 71 with AbstractTracingSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.

the class KafkaConsumerInterceptorTest method testConsumerWithMessage.

@Test
public void testConsumerWithMessage() throws Throwable {
    consumerInterceptor.beforeMethod(consumerInstance, null, new Object[0], new Class[0], null);
    consumerInterceptor.afterMethod(consumerInstance, null, new Object[0], new Class[0], messages);
    List<TraceSegment> traceSegments = segmentStorage.getTraceSegments();
    assertThat(traceSegments.size(), is(1));
    TraceSegment traceSegment = traceSegments.get(0);
    List<TraceSegmentRef> refs = traceSegment.getRefs();
    assertThat(refs.size(), is(1));
    assertTraceSegmentRef(refs.get(0));
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    assertConsumerSpan(spans.get(0));
}
Also used : TraceSegmentRef(org.apache.skywalking.apm.agent.core.context.trace.TraceSegmentRef) AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Example 72 with AbstractTracingSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.

the class TracingContext method createLocalSpan.

/**
 * Create a local span
 *
 * @param operationName most likely a local method signature, or business name.
 * @return the span represents a local logic block.
 * Ref to {@link LocalSpan}
 */
@Override
public AbstractSpan createLocalSpan(final String operationName) {
    if (isLimitMechanismWorking()) {
        NoopSpan span = new NoopSpan();
        return push(span);
    }
    AbstractSpan parentSpan = peek();
    final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId();
    AbstractTracingSpan span = (AbstractTracingSpan) DictionaryManager.findOperationNameCodeSection().findOrPrepare4Register(segment.getApplicationId(), operationName, false, false).doInCondition(new PossibleFound.FoundAndObtain() {

        @Override
        public Object doProcess(int operationId) {
            return new LocalSpan(spanIdGenerator++, parentSpanId, operationId);
        }
    }, new PossibleFound.NotFoundAndObtain() {

        @Override
        public Object doProcess() {
            return new LocalSpan(spanIdGenerator++, parentSpanId, operationName);
        }
    });
    span.start();
    return push(span);
}
Also used : NoopSpan(org.apache.skywalking.apm.agent.core.context.trace.NoopSpan) AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) LocalSpan(org.apache.skywalking.apm.agent.core.context.trace.LocalSpan) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 73 with AbstractTracingSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.

the class SkywalkingSpanActivationTest method testCreateExitSpanWithPeer.

@Test
public void testCreateExitSpanWithPeer() throws Throwable {
    spanBuilder.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).withTag(Tags.PEER_HOST_IPV4.getKey(), "127.0.0.1").withTag(Tags.PEER_PORT.getKey(), "8080");
    startSpan();
    stopSpan();
    TraceSegment tracingSegment = assertTraceSemgnets();
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(tracingSegment);
    assertThat(spans.size(), is(1));
    assertSpanCommonsAttribute(spans.get(0));
    assertThat(spans.get(0).isEntry(), is(false));
    assertThat(spans.get(0).isExit(), is(true));
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Example 74 with AbstractTracingSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.

the class SkywalkingSpanActivationTest method testCreateLocalSpan.

@Test
public void testCreateLocalSpan() throws Throwable {
    startSpan();
    stopSpan();
    TraceSegment tracingSegment = assertTraceSemgnets();
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(tracingSegment);
    assertThat(spans.size(), is(1));
    assertThat(spans.get(0).isEntry(), is(false));
    assertThat(spans.get(0).isExit(), is(false));
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) Test(org.junit.Test)

Example 75 with AbstractTracingSpan

use of org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan in project incubator-skywalking by apache.

the class Struts2InterceptorTest method testWithSerializedContextData.

@Test
public void testWithSerializedContextData() throws Throwable {
    when(request.getHeader(SW3CarrierItem.HEADER_NAME)).thenReturn("1.234.111|3|1|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*");
    struts2Interceptor.beforeMethod(enhancedInstance, null, arguments, argumentType, methodInterceptResult);
    struts2Interceptor.afterMethod(enhancedInstance, null, arguments, argumentType, null);
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertHttpSpan(spans.get(0));
    assertTraceSegmentRef(traceSegment.getRefs().get(0));
}
Also used : AbstractTracingSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan) TraceSegment(org.apache.skywalking.apm.agent.core.context.trace.TraceSegment) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

AbstractTracingSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan)151 TraceSegment (org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)149 Test (org.junit.Test)144 PreparedStatement (java.sql.PreparedStatement)19 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)18 LogDataEntity (org.apache.skywalking.apm.agent.core.context.trace.LogDataEntity)15 SegmentStoragePoint (org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint)14 CallableStatement (java.sql.CallableStatement)13 Method (java.lang.reflect.Method)11 Statement (java.sql.Statement)11 SQLException (java.sql.SQLException)10 KeyValuePair (org.apache.skywalking.apm.agent.core.context.util.KeyValuePair)10 ResultSet (java.sql.ResultSet)7 AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)7 ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)7 Response (feign.Response)3 HashMap (java.util.HashMap)3 Response (okhttp3.Response)3 TraceSegmentRef (org.apache.skywalking.apm.agent.core.context.trace.TraceSegmentRef)3 TextMap (io.opentracing.propagation.TextMap)2