-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
192 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...straps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/util/ScopeUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.navercorp.pinpoint.bootstrap.util; | ||
|
||
import com.navercorp.pinpoint.bootstrap.context.AsyncContext; | ||
import com.navercorp.pinpoint.bootstrap.context.Trace; | ||
import com.navercorp.pinpoint.bootstrap.context.scope.TraceScope; | ||
|
||
public final class ScopeUtils { | ||
|
||
public static final String ASYNC_TRACE_SCOPE = AsyncContext.ASYNC_TRACE_SCOPE; | ||
|
||
private ScopeUtils() { | ||
} | ||
|
||
public static boolean entryAsyncTraceScope(final Trace trace) { | ||
return entryScope(trace, ASYNC_TRACE_SCOPE); | ||
} | ||
|
||
public static boolean entryScope(final Trace trace, final String scopeName) { | ||
final TraceScope scope = trace.getScope(scopeName); | ||
if (scope != null) { | ||
scope.tryEnter(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public static boolean leaveAsyncTraceScope(final Trace trace) { | ||
return leaveScope(trace, ASYNC_TRACE_SCOPE); | ||
} | ||
|
||
public static boolean leaveScope(final Trace trace, final String scopeName) { | ||
final TraceScope scope = trace.getScope(scopeName); | ||
if (scope != null) { | ||
if (scope.canLeave()) { | ||
scope.leave(); | ||
} else { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
public static boolean isAsyncTraceEndScope(final Trace trace) { | ||
return isAsyncTraceEndScope(trace, ASYNC_TRACE_SCOPE); | ||
} | ||
|
||
public static boolean isAsyncTraceEndScope(final Trace trace, final String scopeName) { | ||
if (!trace.isAsync()) { | ||
return false; | ||
} | ||
return isEndScope(trace, scopeName); | ||
} | ||
|
||
public static boolean isEndScope(final Trace trace, final String scopeName) { | ||
final TraceScope scope = trace.getScope(scopeName); | ||
return scope != null && !scope.isActive(); | ||
} | ||
|
||
public static boolean hasScope(final Trace trace, final String scopeName) { | ||
final TraceScope scope = trace.getScope(scopeName); | ||
return scope != null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.