feat: run commands during javaagent startup - #3255
Draft
hengyunabc wants to merge 2 commits into
Draft
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
arthas.startupScriptfor executing UTF-8 command scripts when Arthas starts through-javaagentwatch,line, and other enhancer commands can coexistpremainreturns${arthas.outputPath}/startup/<pid>/<run-id>/arthas-core.jarbesidearthas-agent.jarMotivation
Starting Arthas with
-javaagentcurrently initializes the server but cannot preinstall diagnostic commands. Commands submitted after application startup can miss early class loads or method calls, and one session cannot host multiple foreground long-running commands. This change adds a thin startup orchestration layer on top of the existing command, job, and transformer infrastructure.User impact
The feature is disabled unless
arthas.startupScriptis configured, so existing startup and interactive-session behavior is unchanged. When enabled, a script can contain one Arthas command per line; enhancer commands wait for unloaded target classes automatically, and structured results are persisted without blocking application threads on disk I/O.Example:
arthas.startupScript=/opt/arthas/startup.asValidation
./mvnw -pl core -am test— 291 tests, 0 failures, 7 existing skips./mvnw -f agent/pom.xml -DskipTests package./mvnw -pl packaging -am -DskipTests package— core, site, and distribution build succeeded-javaagentsmoke test with MathGame: twolinejobs and onewatchjob entered lazy mode beforedemo.MathGameloaded, then all produced results in separate JSONL files