You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@skywalking.apache.org by GitBox <gi...@apache.org> on 2018/03/05 10:52:07 UTC

[GitHub] wu-sheng closed pull request #881: [Agent] fix create entry span failure

wu-sheng closed pull request #881: [Agent] fix create entry span failure
URL: https://github.com/apache/incubator-skywalking/pull/881
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java
index 16c9b3218..1bff77743 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java
@@ -248,35 +248,33 @@ public AbstractSpan createEntrySpan(final String operationName) {
         AbstractSpan entrySpan;
         final AbstractSpan parentSpan = peek();
         final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId();
-        if (parentSpan == null) {
+        if (parentSpan != null && parentSpan.isEntry()) {
             entrySpan = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
                 .findOnly(segment.getApplicationId(), operationName)
                 .doInCondition(new PossibleFound.FoundAndObtain() {
                     @Override public Object doProcess(int operationId) {
-                        return new EntrySpan(spanIdGenerator++, parentSpanId, operationId);
+                        return parentSpan.setOperationId(operationId);
                     }
                 }, new PossibleFound.NotFoundAndObtain() {
                     @Override public Object doProcess() {
-                        return new EntrySpan(spanIdGenerator++, parentSpanId, operationName);
+                        return parentSpan.setOperationName(operationName);
                     }
                 });
-            entrySpan.start();
-            return push(entrySpan);
-        } else if (parentSpan.isEntry()) {
+            return entrySpan.start();
+        } else {
             entrySpan = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
                 .findOnly(segment.getApplicationId(), operationName)
                 .doInCondition(new PossibleFound.FoundAndObtain() {
                     @Override public Object doProcess(int operationId) {
-                        return parentSpan.setOperationId(operationId);
+                        return new EntrySpan(spanIdGenerator++, parentSpanId, operationId);
                     }
                 }, new PossibleFound.NotFoundAndObtain() {
                     @Override public Object doProcess() {
-                        return parentSpan.setOperationName(operationName);
+                        return new EntrySpan(spanIdGenerator++, parentSpanId, operationName);
                     }
                 });
-            return entrySpan.start();
-        } else {
-            throw new IllegalStateException("The Entry Span can't be the child of Non-Entry Span");
+            entrySpan.start();
+            return push(entrySpan);
         }
     }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services