You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "wu-sheng (via GitHub)" <gi...@apache.org> on 2023/03/14 07:06:31 UTC
[GitHub] [skywalking-java] wu-sheng commented on a diff in pull request #479: Support keep trace profiling when cross-thread
wu-sheng commented on code in PR #479:
URL: https://github.com/apache/skywalking-java/pull/479#discussion_r1135076370
##########
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:
So, we still have the threshold to control this for limiting the payload, right?
What is the threshold for UI, and what is for agent by default? Are they reasonably matched?
--
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-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org