Conversation
…hing with its shutdown. Also, fix several negligible bugs.
| val methodPool = DescriptorPool<MethodDescriptor>() | ||
| val fieldPool = DescriptorPool<FieldDescriptor>() | ||
| val variablePool = DescriptorPool<VariableDescriptor>() | ||
| private val anonymousThreadCounter = AtomicInteger(0) |
There was a problem hiding this comment.
Why do you need a separate counter for anonymous threads?
Why not just print "anonymous-thread-$id"?
Also, consider changing the thread name to "unknown-thread-$id".
There was a problem hiding this comment.
To create unique names for displaying.
| className.startsWith("sun.rmi.") -> true | ||
| className.startsWith("javax.") -> true | ||
|
|
There was a problem hiding this comment.
These 2 are not spring-related.
There was a problem hiding this comment.
Generally, Spring classes are still shown, so none of the logic makes sense.
|
|
||
| className.startsWith("org.apache.logging.") -> true | ||
| className.startsWith("org.apache.logging.log4j.") -> true | ||
| className.startsWith("org.apache.juli.logging.") -> true |
There was a problem hiding this comment.
Let's move these to isRecognizedLoggingLibraryClass
| ) | ||
| (a.startsWith("set") && b.startsWith("get")) | ||
| || (a.startsWith("get") && b.startsWith("set")) | ||
| ) |
There was a problem hiding this comment.
It's unnecessary indentation change.
The original indentation keeps the same indentation for all disjuncts.
There was a problem hiding this comment.
But it contradicts the official formatting guidelines.
|
|
||
| // Special case: on-line setter and getter for same name can share this line | ||
| for (i in 0 ..< allMethods.size - 1) { | ||
| for (i in 0..<allMethods.size - 1) { |
There was a problem hiding this comment.
IMO 0<..N is harder to read, and it is a weird exception from other binary operators that are surrounded by spaces (e.g., you don't write 0<N, but 0 < N).
I know it's recommended formatting by Kotlin styleguide, but I found it inconvenient and inconsistent.
There was a problem hiding this comment.
BTW, it can be converted to
| for (i in 0..<allMethods.size - 1) { | |
| for (i in allMethods.indices) { |
|
|
||
| if (isRecognizedUninstrumentedThirdPartyLibraryClass(className)) return true | ||
|
|
||
| if (isSpringRelatedClass(className)) return true |
There was a problem hiding this comment.
Let's exclude spring classes only for Trace Recorder for now.
| if (isIntellijRuntimeAgentClass(className)) | ||
| return true | ||
|
|
||
| if (isSpringRelatedClass(className)) |
There was a problem hiding this comment.
Let's exclude spring classes only for Trace Recorder for now.
| * Manages program-scoped trace recording for trace recorder mode. | ||
| * Recording starts at program startup and stops at shutdown via a shutdown hook. | ||
| */ | ||
| internal object ProgramScopedTraceRecorder { |
There was a problem hiding this comment.
Let's just port this logic to Tracer.kt instead of adding a new class here.
I believe this logic is now shared and uniform for both Trace Recorder and Live Debugger, so it makes sense to move it there.
There was a problem hiding this comment.
I think the answer is in this comment: #970 (comment)
Let's not start tracing for premain in case if class and method agent arguments were passed, let's keep the old behavior for this case (at least temporarily).
There was a problem hiding this comment.
So, should I exclude passing the class and method from the Idea plugin side?
| // BinaryFileStream has a race condition where multiple threads can write descriptors | ||
| // in the wrong order due to shared ContextSavingState across threads. | ||
| val effectiveMode = when (mode) { | ||
| is TraceOutputMode.BinaryFileStream -> TraceOutputMode.BinaryFileDump() |
There was a problem hiding this comment.
Let's don't change mode silently. Moreover, binary file dump would not scale as it keeps whole trace in-memory.
If there is a but, then please create a YT issue describing the bug and a reproducer.
| override val tracingEntryPointMethodVisitorProvider: TracingEntryPointMethodVisitorProvider | ||
| get() = ::TraceRecorderMethodTransformer | ||
| override val tracingEntryPointMethodVisitorProvider: TracingEntryPointMethodVisitorProvider? | ||
| get() = null |
There was a problem hiding this comment.
Please rollback.
I believe, at least for backward compatibility reasons, we want to preserve the old behavior for test-like configurations in IDEA plugin. For these configurations, the trace will be started from the test function. If you switch it to static tracing from main right now, it will bloat the trace. We need to fix this problem separately, only after that we can migrate to always starting tracing from main.
For transition period, you can add an option to javaagent arguments. Or check if class and method options were passed, and if not, start tracing from main.


Support the Spring framework by initiating recording from the program's startup and ending with its shutdown.
Additionally, address and resolve several minor bugs.