wu-sheng commented on code in PR #479:
URL: https://github.com/apache/skywalking-java/pull/479#discussion_r1135110743


##########
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/profile/ProfileTaskExecutionContext.java:
##########
@@ -72,39 +72,57 @@ public void stopProfiling() {
      *
      * @return is add profile success
      */
-    public ProfileStatusReference attemptProfiling(TracingContext 
tracingContext,
-                                                   String traceSegmentId,
-                                                   String firstSpanOPName) {
+    public ProfileStatusContext attemptProfiling(TracingContext tracingContext,
+                                                 String traceSegmentId,
+                                                 String firstSpanOPName) {
         // check has available slot
         final int usingSlotCount = currentProfilingCount.get();
         if (usingSlotCount >= Config.Profile.MAX_PARALLEL) {
-            return ProfileStatusReference.createWithNone();
+            return ProfileStatusContext.createWithNone();
         }
 
         // check first operation name matches
         if (!Objects.equals(task.getFirstSpanOPName(), firstSpanOPName)) {
-            return ProfileStatusReference.createWithNone();
+            return ProfileStatusContext.createWithNone();
         }
 
         // if out limit started profiling count then stop add profiling
         if (totalStartedProfilingCount.get() > task.getMaxSamplingCount()) {
-            return ProfileStatusReference.createWithNone();
+            return ProfileStatusContext.createWithNone();
         }
 
         // try to occupy slot
         if (!currentProfilingCount.compareAndSet(usingSlotCount, 
usingSlotCount + 1)) {
-            return ProfileStatusReference.createWithNone();
+            return ProfileStatusContext.createWithNone();
         }
 
+        ThreadProfiler profiler;
+        if ((profiler = addProfilingThread(tracingContext, traceSegmentId)) != 
null) {
+            return profiler.profilingStatus();
+        }
+        return ProfileStatusContext.createWithNone();
+    }
+
+    public boolean continueProfiling(TracingContext tracingContext, String 
traceSegmentId) {
+        // must smaller than max parallels monitoring count
+        if (currentProfilingCount.addAndGet(1) >= Config.Profile.MAX_PARALLEL) 
{
+            currentProfilingCount.addAndGet(-1);
+            return false;
+        }
+
+        return addProfilingThread(tracingContext, traceSegmentId) != null;
+    }

Review Comment:
   I think per-endpoint-access(one main segment)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to