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));
}
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));
}
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);
}
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;
}
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);
}
Aggregations