Fix the profiling segment count not correct (#491)
This commit is contained in:
parent
89e5262f99
commit
db7a14d167
|
|
@ -31,11 +31,13 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
public class ProfileStatusContext {
|
||||
|
||||
private volatile ProfileStatus status;
|
||||
private volatile boolean fromFirstSegment;
|
||||
private volatile long firstSegmentCreateTime;
|
||||
private volatile AtomicInteger subThreadProfilingCount;
|
||||
|
||||
private ProfileStatusContext(ProfileStatus status, long firstSegmentCreateTime, AtomicInteger subThreadProfilingCount) {
|
||||
this.status = status;
|
||||
this.fromFirstSegment = true;
|
||||
this.firstSegmentCreateTime = firstSegmentCreateTime;
|
||||
this.subThreadProfilingCount = subThreadProfilingCount;
|
||||
}
|
||||
|
|
@ -62,6 +64,10 @@ public class ProfileStatusContext {
|
|||
return this.firstSegmentCreateTime;
|
||||
}
|
||||
|
||||
public boolean isFromFirstSegment() {
|
||||
return fromFirstSegment;
|
||||
}
|
||||
|
||||
/**
|
||||
* The profile monitoring is watching, wait for some profile conditions.
|
||||
*/
|
||||
|
|
@ -83,6 +89,7 @@ public class ProfileStatusContext {
|
|||
*/
|
||||
public boolean continued(ContextSnapshot snapshot) {
|
||||
this.status = snapshot.getProfileStatusContext().get();
|
||||
this.fromFirstSegment = false;
|
||||
this.firstSegmentCreateTime = snapshot.getProfileStatusContext().firstSegmentCreateTime();
|
||||
this.subThreadProfilingCount = snapshot.getProfileStatusContext().subThreadProfilingCount;
|
||||
return this.isBeingWatched() &&
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ public class ProfileTaskExecutionContext {
|
|||
|
||||
// update profiling status
|
||||
tracingContext.profileStatus()
|
||||
.updateStatus(attemptProfiling(tracingContext, traceSegmentId, firstSpanOPName));
|
||||
.updateStatus(attemptProfiling(tracingContext, traceSegmentId, firstSpanOPName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -147,7 +147,9 @@ public class ProfileTaskExecutionContext {
|
|||
|
||||
// setting stop running
|
||||
currentProfiler.stopProfiling();
|
||||
currentEndpointProfilingCount.addAndGet(-1);
|
||||
if (currentProfiler.profilingStatus().isFromFirstSegment()) {
|
||||
currentEndpointProfilingCount.addAndGet(-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue