Repository navigation
Conversation
When a start fails after the transformers are installed, the doctor lists the integrations they serve, and the ones waiting for a class to load, as "disabled (agent inactive)", and classes loaded later keep that entry. Incoming servlet requests join the caller's trace only while the agent is active. The servlet advice resolves IncomingRequests.enter and exit once per JVM: the agent publishes the handles in a system property while the servlet integration is enabled, and the advice falls back to the class-loader lookup when the entry is absent. Tests cover the doctor entries after a failed start, the published handles, and async dispatch and forward in the packaged agent.
This branch has not been deployed
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.
What does this PR do?
traceai-javaagent, whenTraceAIAuto.startfails after installing transformers, every integration instrumented by this agent copy (and any still pending class load) is reported as"disabled (agent inactive)"rather than"instrumented"or"pending", and classes loaded later keep that inactive status. Entries held by another copy of the agent in the same JVM keep their status.IncomingRequests.enteralso checksTraceAIAuto.currentRuntime() != nullso incoming servlet requests join a caller's trace only while the agent runtime is active.IncomingRequests.publishAdviceresolvesIncomingRequests.enterandIncomingRequests.exitthrough the system class loader and publishes the twoMethodhandles in system propertytraceai.auto.servlet.advice(putIfAbsent) while the servlet integration is enabled.ServiceAdvicereads those handles directly and falls back to the class-loader lookup when the entry is absent.Why?
When agent startup failed after bytecode transformers were already registered,
doctor()could report integrations as active or pending even though the runtime had been torn down, andIncomingRequests.ServiceAdviceperformed reflective class-loader and method lookups on every servlet request.How was it tested?
New
ServletDoctorStatusTest(11/11 pass): covers disabled SDK (OTEL_SDK_DISABLED=true), active control, failed start after transformer installation marking servlet and pending integrations as"disabled (agent inactive)", late class load after failed start,IncomingRequests.enterreturningnullwhile inactive, andtraceai.auto.servlet.advicehandle publication and fallback.Extended
IncomingRequestsE2ETest(13/13 pass) andServletApp: covers async dispatch and forward propagation in the packaged child-JVM agent.Full
mvn -B -ntp -f java/pom.xml -pl traceai-javaagent -am verify(maven:3.9.9-eclipse-temurin-21):traceai-java-core,traceai-java-annotations,traceai-java-google-adk, andtraceai-javaagentall succeed — 825 unit tests (0 failures, 0 errors, 1 skipped) and 303/303 child-JVM failsafe E2E tests pass.Unit tests added / updated (
JUnit 5)Integration / child-JVM E2E tests pass (
maven-failsafe-plugin)Checklist
docs/VOCABULARY.mdNotes for reviewers
Targets
dev. The per-JVM advice cache is stored as aMethod[]value under system propertytraceai.auto.servlet.adviceonly while the servlet integration is enabled.