Java Code Examples for org.apache.skywalking.apm.agent.core.context.trace.SpanLayer#asHttp()
The following examples show how to use
org.apache.skywalking.apm.agent.core.context.trace.SpanLayer#asHttp() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResinV4Interceptor.java From java-plugin-extensions with Apache License 2.0 | 6 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { CauchoRequest request = (CauchoRequest)allArguments[0]; ContextCarrier contextCarrier = new ContextCarrier(); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); next.setHeadValue(request.getHeader(next.getHeadKey())); } AbstractSpan span = ContextManager.createEntrySpan(request.getPageURI(), contextCarrier); span.setComponent(ComponentsDefine.RESIN); Tags.URL.set(span, appendRequestURL(request)); SpanLayer.asHttp(span); }
Example 2
Source File: ContextManagerTest.java From skywalking with Apache License 2.0 | 6 votes |
@Test public void createSpanWithInvalidateContextCarrier() { ContextCarrier contextCarrier = new ContextCarrier(); AbstractSpan firstEntrySpan = ContextManager.createEntrySpan("/testEntrySpan", contextCarrier); firstEntrySpan.setComponent(ComponentsDefine.TOMCAT); Tags.HTTP.METHOD.set(firstEntrySpan, "GET"); Tags.URL.set(firstEntrySpan, "127.0.0.1:8080"); SpanLayer.asHttp(firstEntrySpan); ContextManager.stopSpan(); TraceSegment actualSegment = tracingData.getTraceSegments().get(0); assertNull(actualSegment.getRefs()); List<AbstractTracingSpan> spanList = SegmentHelper.getSpan(actualSegment); assertThat(Objects.requireNonNull(spanList).size(), is(1)); AbstractTracingSpan actualEntrySpan = spanList.get(0); assertThat(actualEntrySpan.getOperationName(), is("/testEntrySpan")); assertThat(actualEntrySpan.getSpanId(), is(0)); MatcherAssert.assertThat(AbstractTracingSpanHelper.getParentSpanId(actualEntrySpan), is(-1)); }
Example 3
Source File: SenderSendInterceptor.java From skywalking with Apache License 2.0 | 6 votes |
@Override public void beforeMethod(final EnhancedInstance objInst, final Method method, final Object[] allArguments, final Class<?>[] argumentsTypes, final MethodInterceptResult result) throws Throwable { Request req = (Request) objInst.getSkyWalkingDynamicField(); final URI requestURL = req.getUrl().toURI(); final METHOD httpMethod = req.getMethod(); final ContextCarrier contextCarrier = new ContextCarrier(); String remotePeer = requestURL.getHost() + ":" + requestURL.getPort(); AbstractSpan span = ContextManager.createExitSpan(requestURL.getPath(), contextCarrier, remotePeer); span.setComponent(ComponentsDefine.NUTZ_HTTP); Tags.URL.set(span, requestURL.getScheme() + "://" + requestURL.getHost() + ":" + requestURL.getPort() + requestURL .getPath()); Tags.HTTP.METHOD.set(span, httpMethod.toString()); SpanLayer.asHttp(span); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); req.getHeader().set(next.getHeadKey(), next.getHeadValue()); } }
Example 4
Source File: RestExecuteInterceptor.java From skywalking with Apache License 2.0 | 6 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { final URI requestURL = (URI) allArguments[0]; final HttpMethod httpMethod = (HttpMethod) allArguments[1]; final ContextCarrier contextCarrier = new ContextCarrier(); String remotePeer = requestURL.getHost() + ":" + (requestURL.getPort() > 0 ? requestURL.getPort() : "https".equalsIgnoreCase(requestURL .getScheme()) ? 443 : 80); String formatURIPath = requestURL.getPath(); AbstractSpan span = ContextManager.createExitSpan(formatURIPath, contextCarrier, remotePeer); span.setComponent(ComponentsDefine.SPRING_REST_TEMPLATE); Tags.URL.set(span, requestURL.getScheme() + "://" + requestURL.getHost() + ":" + requestURL.getPort() + requestURL .getPath()); Tags.HTTP.METHOD.set(span, httpMethod.toString()); SpanLayer.asHttp(span); Object[] cacheValues = new Object[3]; cacheValues[0] = formatURIPath; cacheValues[1] = contextCarrier; objInst.setSkyWalkingDynamicField(cacheValues); }
Example 5
Source File: TraceSegmentServiceClientTest.java From skywalking with Apache License 2.0 | 6 votes |
@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)); SegmentObject traceSegmentObject = upstreamSegments.get(0); 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)); }
Example 6
Source File: TraceSegmentServiceClientTest.java From skywalking with Apache License 2.0 | 6 votes |
@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)); }
Example 7
Source File: HttpClientWriteRequestInterceptor.java From skywalking with Apache License 2.0 | 6 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { HttpURLConnection connection = (HttpURLConnection) objInst.getSkyWalkingDynamicField(); MessageHeader headers = (MessageHeader) allArguments[0]; URL url = connection.getURL(); ContextCarrier contextCarrier = new ContextCarrier(); AbstractSpan span = ContextManager.createExitSpan(getPath(url), contextCarrier, getPeer(url)); span.setComponent(ComponentsDefine.JDK_HTTP); Tags.HTTP.METHOD.set(span, connection.getRequestMethod()); Tags.URL.set(span, url.toString()); SpanLayer.asHttp(span); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); headers.add(next.getHeadKey(), next.getHeadValue()); } }
Example 8
Source File: HttpClientRequestImplInterceptor.java From skywalking with Apache License 2.0 | 6 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) { HttpClientRequestContext requestContext = (HttpClientRequestContext) objInst.getSkyWalkingDynamicField(); if (!requestContext.sent) { HttpClientRequest request = (HttpClientRequest) objInst; ContextCarrier contextCarrier = new ContextCarrier(); AbstractSpan span = ContextManager.createExitSpan(toPath(request.uri()), contextCarrier, requestContext.remotePeer); span.setComponent(ComponentsDefine.VERTX); SpanLayer.asHttp(span); Tags.HTTP.METHOD.set(span, request.method().toString()); Tags.URL.set(span, request.uri()); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); request.headers().add(next.getHeadKey(), next.getHeadValue()); } requestContext.vertxContext = new VertxContext(ContextManager.capture(), span.prepareForAsync()); } }
Example 9
Source File: Struts2Interceptor.java From skywalking with Apache License 2.0 | 6 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { HttpServletRequest request = ServletActionContext.getRequest(); ContextCarrier contextCarrier = new ContextCarrier(); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); next.setHeadValue(request.getHeader(next.getHeadKey())); } AbstractSpan span = ContextManager.createEntrySpan(request.getRequestURI(), contextCarrier); Tags.URL.set(span, request.getRequestURL().toString()); Tags.HTTP.METHOD.set(span, request.getMethod()); span.setComponent(ComponentsDefine.STRUTS2); SpanLayer.asHttp(span); }
Example 10
Source File: RestExecuteInterceptor.java From skywalking with Apache License 2.0 | 6 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { final URI requestURL = (URI) allArguments[0]; final HttpMethod httpMethod = (HttpMethod) allArguments[1]; final ContextCarrier contextCarrier = new ContextCarrier(); String remotePeer = requestURL.getHost() + ":" + (requestURL.getPort() > 0 ? requestURL.getPort() : "https".equalsIgnoreCase(requestURL .getScheme()) ? 443 : 80); String formatURIPath = requestURL.getPath(); AbstractSpan span = ContextManager.createExitSpan(formatURIPath, contextCarrier, remotePeer); span.setComponent(ComponentsDefine.SPRING_REST_TEMPLATE); Tags.URL.set(span, requestURL.getScheme() + "://" + requestURL.getHost() + ":" + requestURL.getPort() + requestURL .getPath()); Tags.HTTP.METHOD.set(span, httpMethod.toString()); SpanLayer.asHttp(span); objInst.setSkyWalkingDynamicField(contextCarrier); }
Example 11
Source File: ServerConnectionHandleMessageInterceptor.java From skywalking with Apache License 2.0 | 6 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { if (allArguments[0] instanceof HttpRequest) { HttpRequest request = (HttpRequest) allArguments[0]; ContextCarrier contextCarrier = new ContextCarrier(); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); next.setHeadValue(request.headers().get(next.getHeadKey())); request.headers().remove(next.getHeadKey()); } AbstractSpan span = ContextManager.createEntrySpan(toPath(request.getUri()), contextCarrier); span.setComponent(ComponentsDefine.VERTX); SpanLayer.asHttp(span); Tags.HTTP.METHOD.set(span, request.getMethod().toString()); Tags.URL.set(span, request.getUri()); objInst.setSkyWalkingDynamicField(new VertxContext(ContextManager.capture(), span.prepareForAsync())); } }
Example 12
Source File: TomcatInvokeInterceptor.java From skywalking with Apache License 2.0 | 6 votes |
/** * * The {@link TraceSegment#refs} of current trace segment will reference to the trace segment id of the previous * level if the serialized context is not null. * * @param result change this result, if you want to truncate the method. */ @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { Request request = (Request) allArguments[0]; ContextCarrier contextCarrier = new ContextCarrier(); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); next.setHeadValue(request.getHeader(next.getHeadKey())); } AbstractSpan span = ContextManager.createEntrySpan(request.getRequestURI(), contextCarrier); Tags.URL.set(span, request.getRequestURL().toString()); Tags.HTTP.METHOD.set(span, request.getMethod()); span.setComponent(ComponentsDefine.TOMCAT); SpanLayer.asHttp(span); if (Config.Plugin.Tomcat.COLLECT_HTTP_PARAMS) { collectHttpParam(request, span); } }
Example 13
Source File: ActionMethodInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { PathMappingCache pathMappingCache = (PathMappingCache) objInst.getSkyWalkingDynamicField(); String requestURL = pathMappingCache.findPathMapping(method); if (requestURL == null) { At methodRequestMapping = method.getAnnotation(At.class); if (methodRequestMapping.value().length > 0) { requestURL = methodRequestMapping.value()[0]; } else { requestURL = ""; } pathMappingCache.addPathMapping(method, requestURL); requestURL = pathMappingCache.findPathMapping(method); } HttpServletRequest request = Mvcs.getReq(); ContextCarrier contextCarrier = new ContextCarrier(); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); next.setHeadValue(request.getHeader(next.getHeadKey())); } AbstractSpan span = ContextManager.createEntrySpan(requestURL, contextCarrier); Tags.URL.set(span, request.getRequestURL().toString()); Tags.HTTP.METHOD.set(span, request.getMethod()); span.setComponent(ComponentsDefine.NUTZ_MVC_ANNOTATION); SpanLayer.asHttp(span); }
Example 14
Source File: NettySocketIOOnEventInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { String eventName = (String) allArguments[1]; // no place to get context carrier ContextCarrier contextCarrier = new ContextCarrier(); AbstractSpan span = ContextManager.createEntrySpan("SocketIO/" + eventName + "/receive", contextCarrier); span.setComponent(ComponentsDefine.SOCKET_IO); SpanLayer.asHttp(span); }
Example 15
Source File: HttpClientExecuteInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { if (allArguments[0] == null || allArguments[1] == null) { // illegal args, can't trace. ignore. return; } final HttpHost httpHost = (HttpHost) allArguments[0]; HttpRequest httpRequest = (HttpRequest) allArguments[1]; final ContextCarrier contextCarrier = new ContextCarrier(); String remotePeer = httpHost.getHostName() + ":" + port(httpHost); String uri = httpRequest.getRequestLine().getUri(); String requestURI = getRequestURI(uri); String operationName = requestURI; AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, remotePeer); span.setComponent(ComponentsDefine.HTTPCLIENT); Tags.URL.set(span, buildSpanValue(httpHost, uri)); Tags.HTTP.METHOD.set(span, httpRequest.getRequestLine().getMethod()); SpanLayer.asHttp(span); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); httpRequest.setHeader(next.getHeadKey(), next.getHeadValue()); } }
Example 16
Source File: NettySocketIORoomInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { String roomName = (String) allArguments[0]; AbstractSpan span = ContextManager.createLocalSpan("SocketIO/" + roomName + "/" + method.getName()); span.setComponent(ComponentsDefine.SOCKET_IO); SpanLayer.asHttp(span); }
Example 17
Source File: ResinV3Interceptor.java From java-plugin-extensions with Apache License 2.0 | 5 votes |
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { CauchoRequest request = (CauchoRequest)allArguments[0]; ContextCarrier contextCarrier = new ContextCarrier(); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); next.setHeadValue(request.getHeader(next.getHeadKey())); } AbstractSpan span = ContextManager.createEntrySpan(request.getPageURI(), contextCarrier); span.setComponent(ComponentsDefine.RESIN); Tags.URL.set(span, appendRequestURL(request)); SpanLayer.asHttp(span); }
Example 18
Source File: DefaultHttpClientInterceptor.java From skywalking with Apache License 2.0 | 4 votes |
/** * Get the {@link feign.Request} from {@link EnhancedInstance}, then create {@link AbstractSpan} and set host, port, * kind, component, url from {@link feign.Request}. Through the reflection of the way, set the http header of * context data into {@link feign.Request#headers}. * * @param method intercept method * @param result change this result, if you want to truncate the method. * @throws Throwable NoSuchFieldException or IllegalArgumentException */ @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { Request request = (Request) allArguments[0]; URL url = new URL(request.url()); ContextCarrier contextCarrier = new ContextCarrier(); int port = url.getPort() == -1 ? 80 : url.getPort(); String remotePeer = url.getHost() + ":" + port; String operationName = url.getPath(); FeignResolvedURL feignResolvedURL = PathVarInterceptor.URL_CONTEXT.get(); if (feignResolvedURL != null) { try { operationName = operationName.replace(feignResolvedURL.getUrl(), feignResolvedURL.getOriginUrl()); } finally { PathVarInterceptor.URL_CONTEXT.remove(); } } if (operationName.length() == 0) { operationName = "/"; } AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, remotePeer); span.setComponent(ComponentsDefine.FEIGN); Tags.HTTP.METHOD.set(span, request.method()); Tags.URL.set(span, request.url()); SpanLayer.asHttp(span); Field headersField = Request.class.getDeclaredField("headers"); Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(headersField, headersField.getModifiers() & ~Modifier.FINAL); headersField.setAccessible(true); Map<String, Collection<String>> headers = new LinkedHashMap<String, Collection<String>>(); CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); List<String> contextCollection = new LinkedList<String>(); contextCollection.add(next.getHeadValue()); headers.put(next.getHeadKey(), contextCollection); } headers.putAll(request.headers()); headersField.set(request, Collections.unmodifiableMap(headers)); }
Example 19
Source File: ContextManagerTest.java From skywalking with Apache License 2.0 | 4 votes |
@Test public void createMultipleExitSpan() { AbstractSpan entrySpan = ContextManager.createEntrySpan("/testEntrySpan", null); entrySpan.setComponent(ComponentsDefine.TOMCAT); Tags.HTTP.METHOD.set(entrySpan, "GET"); Tags.URL.set(entrySpan, "127.0.0.1:8080"); SpanLayer.asHttp(entrySpan); ContextCarrier firstExitSpanContextCarrier = new ContextCarrier(); AbstractSpan firstExitSpan = ContextManager.createExitSpan( "/testFirstExit", firstExitSpanContextCarrier, "127.0.0.1:8080"); firstExitSpan.setComponent(ComponentsDefine.DUBBO); Tags.URL.set(firstExitSpan, "dubbo://127.0.0.1:8080"); SpanLayer.asRPCFramework(firstExitSpan); ContextCarrier secondExitSpanContextCarrier = new ContextCarrier(); AbstractSpan secondExitSpan = ContextManager.createExitSpan( "/testSecondExit", secondExitSpanContextCarrier, "127.0.0.1:9080"); secondExitSpan.setComponent(ComponentsDefine.TOMCAT); Tags.HTTP.METHOD.set(secondExitSpan, "GET"); Tags.URL.set(secondExitSpan, "127.0.0.1:8080"); SpanLayer.asHttp(secondExitSpan); secondExitSpan.setOperationName("/testSecondExit-setOperationName"); ContextManager.stopSpan(); ContextManager.stopSpan(); ContextManager.stopSpan(); assertThat(tracingData.getTraceSegments().size(), is(1)); TraceSegment actualSegment = tracingData.getTraceSegments().get(0); assertNull(actualSegment.getRefs()); List<AbstractTracingSpan> spanList = SegmentHelper.getSpan(actualSegment); assertThat(Objects.requireNonNull(spanList).size(), is(2)); AbstractTracingSpan actualFirstExitSpan = spanList.get(0); assertThat(actualFirstExitSpan.getOperationName(), is("/testFirstExit")); assertThat(actualFirstExitSpan.getSpanId(), is(1)); assertThat(AbstractTracingSpanHelper.getParentSpanId(actualFirstExitSpan), is(0)); assertThat(SpanHelper.getComponentId(actualFirstExitSpan), is(ComponentsDefine.DUBBO.getId())); assertThat(SpanHelper.getLayer(actualFirstExitSpan), is(SpanLayer.RPC_FRAMEWORK)); AbstractTracingSpan actualEntrySpan = spanList.get(1); assertThat(actualEntrySpan.getOperationName(), is("/testEntrySpan")); assertThat(actualEntrySpan.getSpanId(), is(0)); assertThat(AbstractTracingSpanHelper.getParentSpanId(actualEntrySpan), is(-1)); assertThat(firstExitSpanContextCarrier.getAddressUsedAtClient(), is("127.0.0.1:8080")); assertThat(firstExitSpanContextCarrier.getSpanId(), is(1)); assertThat(secondExitSpanContextCarrier.getSpanId(), is(1)); }
Example 20
Source File: ContextManagerTest.java From skywalking with Apache License 2.0 | 4 votes |
@Test public void createMultipleEntrySpan() { ContextCarrier contextCarrier = new ContextCarrier().deserialize( "1-My40LjU=-MS4yLjM=-4-c2VydmljZQ==-aW5zdGFuY2U=-L2FwcA==-MTI3LjAuMC4xOjgwODA=", ContextCarrier.HeaderVersion.v3 ); assertTrue(contextCarrier.isValid()); AbstractSpan firstEntrySpan = ContextManager.createEntrySpan("/testFirstEntry", contextCarrier); firstEntrySpan.setComponent(ComponentsDefine.TOMCAT); Tags.HTTP.METHOD.set(firstEntrySpan, "GET"); Tags.URL.set(firstEntrySpan, "127.0.0.1:8080"); SpanLayer.asHttp(firstEntrySpan); AbstractSpan secondEntrySpan = ContextManager.createEntrySpan("/testSecondEntry", contextCarrier); secondEntrySpan.setComponent(ComponentsDefine.DUBBO); Tags.URL.set(firstEntrySpan, "dubbo://127.0.0.1:8080"); SpanLayer.asRPCFramework(secondEntrySpan); ContextCarrier injectContextCarrier = new ContextCarrier(); AbstractSpan exitSpan = ContextManager.createExitSpan("/textExitSpan", injectContextCarrier, "127.0.0.1:12800"); exitSpan.errorOccurred(); exitSpan.log(new RuntimeException("exception")); exitSpan.setComponent(ComponentsDefine.HTTPCLIENT); ContextManager.stopSpan(); ContextManager.stopSpan(); SpanLayer.asHttp(firstEntrySpan); firstEntrySpan.setOperationName("/testFirstEntry-setOperationName"); ContextManager.stopSpan(); assertThat(tracingData.getTraceSegments().size(), is(1)); TraceSegment actualSegment = tracingData.getTraceSegments().get(0); assertThat(actualSegment.getRefs().size(), is(1)); TraceSegmentRef ref = actualSegment.getRefs().get(0); MatcherAssert.assertThat(TraceSegmentRefHelper.getPeerHost(ref), is("127.0.0.1:8080")); List<AbstractTracingSpan> spanList = SegmentHelper.getSpan(actualSegment); assertThat(spanList.size(), is(2)); AbstractTracingSpan actualEntrySpan = spanList.get(1); assertThat(actualEntrySpan.getOperationName(), is("/testSecondEntry")); assertThat(actualEntrySpan.getSpanId(), is(0)); assertThat(AbstractTracingSpanHelper.getParentSpanId(actualEntrySpan), is(-1)); assertThat(SpanHelper.getComponentId(actualEntrySpan), is(ComponentsDefine.DUBBO.getId())); assertThat(SpanHelper.getLayer(actualEntrySpan), is(SpanLayer.RPC_FRAMEWORK)); AbstractTracingSpan actualExitSpan = spanList.get(0); assertThat(actualExitSpan.getOperationName(), is("/textExitSpan")); assertThat(actualExitSpan.getSpanId(), is(1)); assertThat(AbstractTracingSpanHelper.getParentSpanId(actualExitSpan), is(0)); List<LogDataEntity> logs = AbstractTracingSpanHelper.getLogs(actualExitSpan); assertThat(logs.size(), is(1)); assertThat(logs.get(0).getLogs().size(), is(4)); assertThat(injectContextCarrier.getSpanId(), is(1)); assertThat(injectContextCarrier.getAddressUsedAtClient(), is("127.0.0.1:12800")); }