-
Notifications
You must be signed in to change notification settings - Fork 47
Implement method call stack tracing #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Scavenger Test Results178 files 178 suites 3m 28s ⏱️ Results for commit cf1d43d. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review. I only checked the agent and api modules first.
- Is it possible to see the call stack tree maybe?
- Also, could you please change the vitess configuration file.
...agent-java/src/main/java/com/navercorp/scavenger/javaagent/collecting/CallStackRegistry.java
Outdated
Show resolved
Hide resolved
...agent-java/src/main/java/com/navercorp/scavenger/javaagent/collecting/CallStackRegistry.java
Outdated
Show resolved
Hide resolved
...agent-java/src/main/java/com/navercorp/scavenger/javaagent/collecting/CallStackRegistry.java
Outdated
Show resolved
Hide resolved
...-agent-java/src/main/java/com/navercorp/scavenger/javaagent/collecting/CallStackTracker.java
Show resolved
Hide resolved
@@ -81,7 +88,9 @@ public class SchedulerTest { | |||
public void setUp() throws Exception { | |||
lenient().when(codeBaseScannerMock.scan()) | |||
.thenReturn(new CodeBase(List.of(Method.createTestMethod()), "fingerprint")); | |||
sut = new Scheduler(invocationRegistry, new Config(new Properties()), publisher, codeBaseScannerMock); | |||
Properties properties = new Properties(); | |||
properties.setProperty("callStackTraceMode", "true"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it more clear, it also needs to be tested when callStackTraceMode
is false
scavenger-agent-java/src/main/java/com/navercorp/scavenger/javaagent/scheduling/Scheduler.java
Outdated
Show resolved
Hide resolved
invokedAtMillis: Long?, | ||
): String = | ||
""" | ||
SELECT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check query performance?
EXPLAIN FORMAT=VITESS {query}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply :(
Here is the Vitess query plan
+----------+-------------------+----------+-------------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| operator | variant | keyspace | destination | tabletType | query |
+----------+-------------------+----------+-------------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Route | SelectEqualUnique | main | | UNKNOWN | select caller_methods.signature as callerSignature from call_stacks join methods as callee_methods on call_stacks.customerId = callee_methods.customerId and call_stacks.signatureHash = callee_methods.signatureHash join methods as caller_methods on call_stacks.customerId = caller_methods.customerId and call_stacks.callerSignatureHash = caller_methods.signatureHash where callee_methods.signature = '${PATH}' and call_stacks.customerId = 11000002003 and call_stacks.applicationId in (11003142347) and call_stacks.environmentId in (11003142346) and (1751941260000 is null or call_stacks.invokedAtMillis >= 1751941260000) |
+----------+-------------------+----------+-------------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
scavenger-collector/src/main/kotlin/com/navercorp/scavenger/controller/GrpcAgentController.kt
Outdated
Show resolved
Hide resolved
scavenger-api/src/main/kotlin/com/navercorp/scavenger/repository/sql/CallStackSql.kt
Outdated
Show resolved
Hide resolved
@@ -59,7 +59,7 @@ class MethodDao( | |||
return 0 | |||
} | |||
return update( | |||
sql.deleteAllMethodsAndInvocations(), | |||
sql.deleteAllMethods(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
In the current PR, the implementation is based on a one-way |
@sohyun-ku This is a great idea, and for an early version, this is great!! |
I think it is technically possible to build a tree from a specific callee up to the root However, the stored call data represents multiple call records across the application rather than a single call flow. Additionally, since the call graph may contain cycles and paths can get deep, In summary, while extending the tree up to the root is feasible, please note that this does not exactly reproduce a single actual call flow that triggered the callee. Due to the necessity of minimizing the performance impact on the agent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 👍 👍 👍 👍
@sohyun-ku yes I understand, thanks for the clarification. 😄 |
resolved: implement method call stack #109
Call Stack Tracing with ConcurrentHashMap + Deque
ConcurrentHashMap<Long, ArrayDeque<String>>.
Deque
), and method entries and exits are tracked viapush
andpop
operations respectively.Deque
is used as a stack to accurately capture the order and depth of method calls.Caller-Callee Based Lightweight Call Structure
and can be effectively used for incremental exploration or future enhancements such as call relationship visualization.
Benchmark Results (
ns/op
)CallStackTraceMode
introduces some overhead, the feature is implemented as optional, allowing it to be turned on only when detailed call tracing is needed.Snapshot: Caller-Callee Relationship Example