Search in sources :

Example 96 with AbstractSpan

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

the class TraceSegmentServiceClientTest method testSendTraceSegmentWithoutException.

@Test
public void testSendTraceSegmentWithoutException() throws InvalidProtocolBufferException {
    grpcServerRule.getServiceRegistry().addService(serviceImplBase);
    AbstractSpan firstEntrySpan = ContextManager.createEntrySpan("/testFirstEntry", null);
    firstEntrySpan.setComponent(ComponentsDefine.TOMCAT);
    Tags.HTTP.METHOD.set(firstEntrySpan, "GET");
    Tags.URL.set(firstEntrySpan, "127.0.0.1:8080");
    SpanLayer.asHttp(firstEntrySpan);
    ContextManager.stopSpan();
    serviceClient.consume(storage.getTraceSegments());
    assertThat(upstreamSegments.size(), is(1));
    UpstreamSegment upstreamSegment = upstreamSegments.get(0);
    assertThat(upstreamSegment.getGlobalTraceIdsCount(), is(1));
    TraceSegmentObject traceSegmentObject = TraceSegmentObject.parseFrom(upstreamSegment.getSegment());
    assertThat(traceSegmentObject.getSpans(0).getRefsCount(), is(0));
    assertThat(traceSegmentObject.getSpansCount(), is(1));
    SpanObject spanObject = traceSegmentObject.getSpans(0);
    assertThat(spanObject.getSpanType(), is(SpanType.Entry));
    assertThat(spanObject.getSpanId(), is(0));
    assertThat(spanObject.getParentSpanId(), is(-1));
}
Also used : UpstreamSegment(org.apache.skywalking.apm.network.proto.UpstreamSegment) TraceSegmentObject(org.apache.skywalking.apm.network.proto.TraceSegmentObject) SpanObject(org.apache.skywalking.apm.network.proto.SpanObject) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 97 with AbstractSpan

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

the class TraceSegmentServiceClientTest method testSendTraceSegmentWithException.

@Test
public void testSendTraceSegmentWithException() throws InvalidProtocolBufferException {
    grpcServerRule.getServiceRegistry().addService(serviceImplBase);
    AbstractSpan firstEntrySpan = ContextManager.createEntrySpan("/testFirstEntry", null);
    firstEntrySpan.setComponent(ComponentsDefine.TOMCAT);
    Tags.HTTP.METHOD.set(firstEntrySpan, "GET");
    Tags.URL.set(firstEntrySpan, "127.0.0.1:8080");
    SpanLayer.asHttp(firstEntrySpan);
    ContextManager.stopSpan();
    grpcServerRule.getServer().shutdownNow();
    serviceClient.consume(storage.getTraceSegments());
    assertThat(upstreamSegments.size(), is(0));
    boolean reconnect = Whitebox.getInternalState(ServiceManager.INSTANCE.findService(GRPCChannelManager.class), "reconnect");
    assertThat(reconnect, is(true));
}
Also used : AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 98 with AbstractSpan

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

the class BlockingCallClientInterceptor method start.

@Override
public void start(Listener responseListener, Metadata headers) {
    final AbstractSpan span = ContextManager.createExitSpan(serviceName, remotePeer);
    span.setComponent(ComponentsDefine.GRPC);
    SpanLayer.asRPCFramework(span);
    final ContextCarrier contextCarrier = new ContextCarrier();
    ContextManager.inject(contextCarrier);
    CarrierItem contextItem = contextCarrier.items();
    while (contextItem.hasNext()) {
        contextItem = contextItem.next();
        Metadata.Key<String> headerKey = Metadata.Key.of(contextItem.getHeadKey(), Metadata.ASCII_STRING_MARSHALLER);
        headers.put(headerKey, contextItem.getHeadValue());
    }
    delegate().start(new CallListener(responseListener), headers);
}
Also used : ContextCarrier(org.apache.skywalking.apm.agent.core.context.ContextCarrier) CarrierItem(org.apache.skywalking.apm.agent.core.context.CarrierItem) ForwardingClientCallListener(io.grpc.ForwardingClientCallListener) Metadata(io.grpc.Metadata) AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 99 with AbstractSpan

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

the class ContextManager method createExitSpan.

public static AbstractSpan createExitSpan(String operationName, ContextCarrier carrier, String remotePeer) {
    if (carrier == null) {
        throw new IllegalArgumentException("ContextCarrier can't be null.");
    }
    AbstractTracerContext context = getOrCreate(operationName, false);
    AbstractSpan span = context.createExitSpan(operationName, remotePeer);
    context.inject(carrier);
    return span;
}
Also used : AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Example 100 with AbstractSpan

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

the class ConnectIterceptor method handleMethodException.

@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Throwable t) {
    AbstractSpan activeSpan = ContextManager.activeSpan();
    activeSpan.errorOccurred();
    activeSpan.log(t);
}
Also used : AbstractSpan(org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)

Aggregations

AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)141 ContextCarrier (org.apache.skywalking.apm.agent.core.context.ContextCarrier)36 CarrierItem (org.apache.skywalking.apm.agent.core.context.CarrierItem)29 URI (java.net.URI)7 AbstractTracingSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan)7 TraceSegment (org.apache.skywalking.apm.agent.core.context.trace.TraceSegment)7 ConnectionInfo (org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 StatementEnhanceInfos (org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos)6 Invocation (io.servicecomb.core.Invocation)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 Invocation (org.apache.servicecomb.core.Invocation)5 SQLException (java.sql.SQLException)4 Metadata (io.grpc.Metadata)3 Field (java.lang.reflect.Field)3 List (java.util.List)3 TraceSegmentRef (org.apache.skywalking.apm.agent.core.context.trace.TraceSegmentRef)3 EnhancedInstance (org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance)3 Request (com.weibo.api.motan.rpc.Request)2 Response (com.weibo.api.motan.rpc.Response)2