diff --git a/apm-network/src/main/proto/TraceSegmentService.proto b/apm-network/src/main/proto/TraceSegmentService.proto index a1e0aa134f239991b3e9a10f703b2b941da70d54..1a1116a134f60959b690f05f0a7efa2869eb0040 100644 --- a/apm-network/src/main/proto/TraceSegmentService.proto +++ b/apm-network/src/main/proto/TraceSegmentService.proto @@ -37,8 +37,9 @@ message TraceSegmentReference { int32 networkAddressId = 6; string entryServiceName = 7; int32 entryServiceId = 8; - string parentServiceName = 9; - int32 parentServiceId = 10; + int32 entryServiceApplicationInstanceId = 9; + string parentServiceName = 10; + int32 parentServiceId = 11; } message SpanObject { diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java index 1b94a3e25b87a09df3287f249ed74361832be74c..9e60019e24449ddc1960d67123f8634446a82a96 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java @@ -10,10 +10,8 @@ import org.skywalking.apm.agent.core.dictionary.DictionaryUtil; import org.skywalking.apm.util.StringUtil; /** - * {@link ContextCarrier} is a data carrier of {@link TracingContext}. - * It holds the snapshot (current state) of {@link TracingContext}. - *

- * Created by wusheng on 2017/2/17. + * {@link ContextCarrier} is a data carrier of {@link TracingContext}. It holds the snapshot (current state) of {@link + * TracingContext}.

Created by wusheng on 2017/2/17. */ public class ContextCarrier implements Serializable { /** @@ -36,9 +34,10 @@ public class ContextCarrier implements Serializable { */ private DistributedTraceId primaryDistributedTraceId; + private int entryApplicationInstanceId = DictionaryUtil.nullValue(); + /** - * Serialize this {@link ContextCarrier} to a {@link String}, - * with '|' split. + * Serialize this {@link ContextCarrier} to a {@link String}, with '|' split. * * @return the serialization string. */ @@ -51,7 +50,8 @@ public class ContextCarrier implements Serializable { this.getPeerHost(), this.getEntryOperationName(), this.getParentOperationName(), - this.getPrimaryDistributedTraceId()); + this.getPrimaryDistributedTraceId(), + this.getEntryApplicationInstanceId() + ""); } else { return ""; } @@ -64,8 +64,8 @@ public class ContextCarrier implements Serializable { */ public ContextCarrier deserialize(String text) { if (text != null) { - String[] parts = text.split("\\|", 7); - if (parts.length == 7) { + String[] parts = text.split("\\|", 8); + if (parts.length == 8) { try { this.traceSegmentId = new ID(parts[0]); this.spanId = Integer.parseInt(parts[1]); @@ -74,6 +74,7 @@ public class ContextCarrier implements Serializable { this.entryOperationName = parts[4]; this.parentOperationName = parts[5]; this.primaryDistributedTraceId = new PropagatedTraceId(parts[6]); + this.entryApplicationInstanceId = Integer.parseInt(parts[7]); } catch (NumberFormatException e) { } @@ -94,7 +95,8 @@ public class ContextCarrier implements Serializable { && !StringUtil.isEmpty(peerHost) && !StringUtil.isEmpty(entryOperationName) && !StringUtil.isEmpty(parentOperationName) - && primaryDistributedTraceId != null; + && primaryDistributedTraceId != null + && entryApplicationInstanceId != DictionaryUtil.nullValue(); } public String getEntryOperationName() { @@ -168,4 +170,12 @@ public class ContextCarrier implements Serializable { public String getParentOperationName() { return parentOperationName; } + + public void setEntryApplicationInstanceId(int entryApplicationInstanceId) { + this.entryApplicationInstanceId = entryApplicationInstanceId; + } + + public int getEntryApplicationInstanceId() { + return entryApplicationInstanceId; + } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java index b0fab5fe3b2489a2e15ad729fbcbc6bbff790242..362420fb8082bc038fb7679fbbcccda04a1a28ba 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java @@ -84,7 +84,7 @@ public class TracingContext implements AbstractTracerContext { carrier.setTraceSegmentId(this.segment.getTraceSegmentId()); carrier.setSpanId(span.getSpanId()); - carrier.setApplicationInstanceId(segment.getApplicationId()); + carrier.setApplicationInstanceId(segment.getApplicationInstanceId()); if (DictionaryUtil.isNull(exitSpan.getPeerId())) { carrier.setPeerHost(exitSpan.getPeer()); @@ -102,6 +102,7 @@ public class TracingContext implements AbstractTracerContext { AbstractTracingSpan firstSpan = first(); operationId = firstSpan.getOperationId(); operationName = firstSpan.getOperationName(); + carrier.setEntryApplicationInstanceId(this.segment.getApplicationInstanceId()); } if (operationId == DictionaryUtil.nullValue()) { carrier.setEntryOperationName(operationName); diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegment.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegment.java index 6857c8b8f46da4ed8e3db72fa2400665fe085d74..564c297baf57d0e7c67d11310d782d9d54efdd1e 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegment.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegment.java @@ -191,4 +191,8 @@ public class TraceSegment { ", relatedGlobalTraces=" + relatedGlobalTraces + '}'; } + + public int getApplicationInstanceId() { + return RemoteDownstreamConfig.Agent.APPLICATION_INSTANCE_ID; + } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java index 74dc4bff9806ade5f43c65cd9d27177baea22b12..d39564bdb5ae2f8eb5c7cdba9368b9e67ca00f6f 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java @@ -30,6 +30,8 @@ public class TraceSegmentRef { private int entryOperationId = DictionaryUtil.nullValue(); + private int entryApplicationInstanceId = DictionaryUtil.nullValue(); + private String parentOperationName; private int parentOperationId = DictionaryUtil.nullValue(); @@ -44,6 +46,7 @@ public class TraceSegmentRef { this.traceSegmentId = carrier.getTraceSegmentId(); this.spanId = carrier.getSpanId(); this.applicationInstanceId = carrier.getApplicationInstanceId(); + this.entryApplicationInstanceId = carrier.getEntryApplicationInstanceId(); String host = carrier.getPeerHost(); if (host.charAt(0) == '#') { this.peerHost = host.substring(1); @@ -95,6 +98,7 @@ public class TraceSegmentRef { if (SegmentRefType.CROSS_PROCESS.equals(type)) { refBuilder.setRefType(RefType.CrossProcess); refBuilder.setParentApplicationInstanceId(applicationInstanceId); + refBuilder.setEntryServiceApplicationInstanceId(entryApplicationInstanceId); if (peerId == DictionaryUtil.nullValue()) { refBuilder.setNetworkAddress(peerHost); } else { diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/ContextManagerTest.java b/apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/ContextManagerTest.java index e0b6af6911e4c0cfcce4ff65aab68e7cc77db4d5..118bb0940828213b2926523bc38a062e18884888 100644 --- a/apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/ContextManagerTest.java +++ b/apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/ContextManagerTest.java @@ -79,7 +79,7 @@ public class ContextManagerTest { @Test public void createMultipleEntrySpan() { - ContextCarrier contextCarrier = new ContextCarrier().deserialize("#AQA*#AQA*4WcWe0tQNQA*|1|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"); + ContextCarrier contextCarrier = new ContextCarrier().deserialize("#AQA*#AQA*4WcWe0tQNQA*|1|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*|1"); assertTrue(contextCarrier.isValid()); AbstractSpan firstEntrySpan = ContextManager.createEntrySpan("/testFirstEntry", contextCarrier); @@ -202,7 +202,7 @@ public class ContextManagerTest { @Test public void testTransform() throws InvalidProtocolBufferException { - ContextCarrier contextCarrier = new ContextCarrier().deserialize("#AQA*#AQA*4WcWe0tQNQA*|3|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"); + ContextCarrier contextCarrier = new ContextCarrier().deserialize("#AQA*#AQA*4WcWe0tQNQA*|3|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*|1"); assertTrue(contextCarrier.isValid()); AbstractSpan firstEntrySpan = ContextManager.createEntrySpan("/testFirstEntry", contextCarrier); diff --git a/apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java index 380cc56f2016b9e475cd9c99a275829845e92174..686e5ea7cb5df50f5f218da6f2f8dbeb5cd03d26 100644 --- a/apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java @@ -148,7 +148,7 @@ public class DubboInterceptorTest { @Test public void testProviderWithAttachment() throws Throwable { when(rpcContext.isConsumerSide()).thenReturn(false); - when(rpcContext.getAttachment(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8 :18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"); + when(rpcContext.getAttachment(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8 :18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*|1"); dubboInterceptor.beforeMethod(enhancedInstance, "invoke", allArguments, argumentTypes, methodInterceptResult); dubboInterceptor.afterMethod(enhancedInstance, "invoke", allArguments, argumentTypes, result); @@ -160,7 +160,7 @@ public class DubboInterceptorTest { when(rpcContext.isConsumerSide()).thenReturn(false); FieldSetter.setStaticValue(BugFixActive.class, "ACTIVE", true); - testParam.setTraceContext("#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8 :18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"); + testParam.setTraceContext("#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8 :18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*|1"); dubboInterceptor.beforeMethod(enhancedInstance, "invoke", allArguments, argumentTypes, methodInterceptResult); dubboInterceptor.afterMethod(enhancedInstance, "invoke", allArguments, argumentTypes, result); @@ -194,6 +194,7 @@ public class DubboInterceptorTest { private void assertTraceSegmentRef(TraceSegmentRef actual) { assertThat(SegmentRefHelper.getSpanId(actual), is(3)); + assertThat(SegmentRefHelper.getEntryApplicationInstanceId(actual), is(1)); assertThat(SegmentRefHelper.getTraceSegmentId(actual).toString(), is("1.1.15006458883500001")); } diff --git a/apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptorTest.java index fe7541112d7b8647c08d0ca78fdcd51e6b79aeb7..d94329d68f9e83fb4eac0dc933665fb21844ca44 100644 --- a/apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptorTest.java @@ -91,7 +91,7 @@ public class MotanProviderInterceptorTest { @Test public void testInvokerWithRefSegment() throws Throwable { HashMap attachments = new HashMap(); - attachments.put(Config.Plugin.Propagation.HEADER_NAME, "#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"); + attachments.put(Config.Plugin.Propagation.HEADER_NAME, "#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*|1"); when(request.getAttachments()).thenReturn(attachments); invokeInterceptor.beforeMethod(enhancedInstance, "execute", arguments, argumentType, null); @@ -137,6 +137,7 @@ public class MotanProviderInterceptorTest { private void assertRefSegment(TraceSegmentRef primaryRef) { assertThat(SegmentRefHelper.getTraceSegmentId(primaryRef).toString(), is("1.1.15006458883500001")); assertThat(SegmentRefHelper.getSpanId(primaryRef), is(3)); + assertThat(SegmentRefHelper.getEntryApplicationInstanceId(primaryRef), is(1)); assertThat(SegmentRefHelper.getPeerHost(primaryRef), is("192.168.1.8:18002")); } diff --git a/apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v3/ResinV3InterceptorTest.java b/apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v3/ResinV3InterceptorTest.java index 71b3e35d6fdbaa340d5f1b6569ea16dd5f5a35ba..1142c12270a4bed852b8243c539feef1ed2c5f50 100644 --- a/apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v3/ResinV3InterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v3/ResinV3InterceptorTest.java @@ -90,7 +90,7 @@ public class ResinV3InterceptorTest { @Test public void testWithSerializedContextData() throws Throwable { - when(request.getHeader(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"); + when(request.getHeader(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*|1"); interceptor.beforeMethod(enhancedInstance, "service", arguments, argumentType, methodInterceptResult); interceptor.afterMethod(enhancedInstance, "service", arguments, argumentType, null); @@ -121,6 +121,7 @@ public class ResinV3InterceptorTest { private void assertTraceSegmentRef(TraceSegmentRef ref) { assertThat(SegmentRefHelper.getSpanId(ref), is(3)); + assertThat(SegmentRefHelper.getEntryApplicationInstanceId(ref), is(1)); assertThat(SegmentRefHelper.getTraceSegmentId(ref).toString(), is("1.1.15006458883500001")); } diff --git a/apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v4/ResinV4InterceptorTest.java b/apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v4/ResinV4InterceptorTest.java index 280211f6f20d8bbb6652d43dc0225217925dd9ee..e1a9f951965acbe6bcaac2c060b2ada6df1aff4c 100644 --- a/apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v4/ResinV4InterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v4/ResinV4InterceptorTest.java @@ -92,7 +92,7 @@ public class ResinV4InterceptorTest { @Test public void testWithSerializedContextData() throws Throwable { - when(request.getHeader(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"); + when(request.getHeader(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*|1"); interceptor.beforeMethod(enhancedInstance, "service", arguments, argumentType, methodInterceptResult); interceptor.afterMethod(enhancedInstance, "service", arguments, argumentType, null); @@ -122,6 +122,7 @@ public class ResinV4InterceptorTest { } private void assertTraceSegmentRef(TraceSegmentRef ref) { + assertThat(SegmentRefHelper.getEntryApplicationInstanceId(ref), is(1)); assertThat(SegmentRefHelper.getSpanId(ref), is(3)); assertThat(SegmentRefHelper.getTraceSegmentId(ref).toString(), is("1.1.15006458883500001")); } diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/org/skywalking/apm/plugin/tomcat78x/TomcatInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/org/skywalking/apm/plugin/tomcat78x/TomcatInterceptorTest.java index 19b94a5b203327a0d7b084f043b5929a5bc87da7..550fe1ed190ef9e067b4fa9c353ba471db55ad37 100644 --- a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/org/skywalking/apm/plugin/tomcat78x/TomcatInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/org/skywalking/apm/plugin/tomcat78x/TomcatInterceptorTest.java @@ -82,7 +82,7 @@ public class TomcatInterceptorTest { @Test public void testWithSerializedContextData() throws Throwable { - when(request.getHeader(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"); + when(request.getHeader(Config.Plugin.Propagation.HEADER_NAME)).thenReturn("#AQA*#AQA*4WcWe0tQNQA*|3|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*|1"); tomcatInterceptor.beforeMethod(enhancedInstance, "invoke", arguments, argumentType, methodInterceptResult); tomcatInterceptor.afterMethod(enhancedInstance, "invoke", arguments, argumentType, null); @@ -112,6 +112,7 @@ public class TomcatInterceptorTest { } private void assertTraceSegmentRef(TraceSegmentRef ref) { + assertThat(SegmentRefHelper.getEntryApplicationInstanceId(ref), is(1)); assertThat(SegmentRefHelper.getSpanId(ref), is(3)); assertThat(SegmentRefHelper.getTraceSegmentId(ref).toString(), is("1.1.15006458883500001")); } diff --git a/apm-sniffer/apm-test-tools/src/main/java/org/skywalking/apm/agent/test/helper/SegmentRefHelper.java b/apm-sniffer/apm-test-tools/src/main/java/org/skywalking/apm/agent/test/helper/SegmentRefHelper.java index f0ce5286048b7701b31dbd223798bf0abccd2593..38fb32a20d5aeba9ae6a3e7d881e919ac3a8945d 100644 --- a/apm-sniffer/apm-test-tools/src/main/java/org/skywalking/apm/agent/test/helper/SegmentRefHelper.java +++ b/apm-sniffer/apm-test-tools/src/main/java/org/skywalking/apm/agent/test/helper/SegmentRefHelper.java @@ -30,4 +30,13 @@ public class SegmentRefHelper { return -1; } + + public static int getEntryApplicationInstanceId(TraceSegmentRef ref) { + try { + return FieldGetter.getValue(ref, "entryApplicationInstanceId"); + } catch (Exception e) { + } + + return -1; + } } diff --git a/apm-sniffer/apm-test-tools/src/main/java/org/skywalking/apm/agent/test/tools/SegmentRefAssert.java b/apm-sniffer/apm-test-tools/src/main/java/org/skywalking/apm/agent/test/tools/SegmentRefAssert.java index c5d88304a5f0759b782546f6641a76a0cb4ccc0b..f61751d6d8f5e977de469d76bd650215a2451e63 100644 --- a/apm-sniffer/apm-test-tools/src/main/java/org/skywalking/apm/agent/test/tools/SegmentRefAssert.java +++ b/apm-sniffer/apm-test-tools/src/main/java/org/skywalking/apm/agent/test/tools/SegmentRefAssert.java @@ -18,4 +18,9 @@ public class SegmentRefAssert { public static void assertPeerHost(TraceSegmentRef ref, String peerHost) { assertThat(SegmentRefHelper.getPeerHost(ref), is(peerHost)); } + + public static void assertEntryApplicationInstanceId(TraceSegmentRef ref, int entryApplicationInstanceID) { + assertThat(SegmentRefHelper.getEntryApplicationInstanceId(ref), is(entryApplicationInstanceID)); + } + } diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/test/java/org/skywalking/apm/toolkit/activation/opentracing/SkywalkingSpanActivationTest.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/test/java/org/skywalking/apm/toolkit/activation/opentracing/SkywalkingSpanActivationTest.java index 474ce177761cca7e9eb578f5d008c5839ac692a9..2421705fa5516313a94aafe87b6d6ce720d35501 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/test/java/org/skywalking/apm/toolkit/activation/opentracing/SkywalkingSpanActivationTest.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/test/java/org/skywalking/apm/toolkit/activation/opentracing/SkywalkingSpanActivationTest.java @@ -17,6 +17,7 @@ import org.skywalking.apm.agent.core.context.trace.TraceSegment; import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; import org.skywalking.apm.agent.test.helper.SegmentHelper; +import org.skywalking.apm.agent.test.helper.SegmentRefHelper; import org.skywalking.apm.agent.test.tools.AgentServiceRule; import org.skywalking.apm.agent.test.tools.SegmentStorage; import org.skywalking.apm.agent.test.tools.SegmentStoragePoint; @@ -37,6 +38,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.skywalking.apm.agent.test.tools.SegmentRefAssert.assertPeerHost; import static org.skywalking.apm.agent.test.tools.SegmentRefAssert.assertSegmentId; +import static org.skywalking.apm.agent.test.tools.SegmentRefAssert.assertEntryApplicationInstanceId; import static org.skywalking.apm.agent.test.tools.SegmentRefAssert.assertSpanId; import static org.skywalking.apm.agent.test.tools.SpanAssert.assertComponent; import static org.skywalking.apm.agent.test.tools.SpanAssert.assertLogSize; @@ -181,7 +183,7 @@ public class SkywalkingSpanActivationTest { .withTag(Tags.PEER_HOST_IPV4.getKey(), "127.0.0.1").withTag(Tags.PEER_PORT.getKey(), 8080); startSpan(); extractInterceptor.afterMethod(enhancedInstance, "extract", - new Object[] {"#AQA*#AQA*4WcWe0tQNQA*|3|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*"}, new Class[] {String.class}, null); + new Object[] {"#AQA*#AQA*4WcWe0tQNQA*|3|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*|1"}, new Class[] {String.class}, null); stopSpan(); TraceSegment tracingSegment = assertTraceSemgnets(); @@ -190,11 +192,11 @@ public class SkywalkingSpanActivationTest { TraceSegmentRef ref = tracingSegment.getRefs().get(0); assertSegmentId(ref, "1.1.15006458883500001"); assertSpanId(ref, 3); + assertEntryApplicationInstanceId(ref, 1); assertPeerHost(ref, "127.0.0.1:8080"); assertThat(spans.size(), is(1)); assertSpanCommonsAttribute(spans.get(0)); } - @Test public void testExtractWithInValidateContext() throws Throwable { spanBuilder.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)