Add an experimental observer agent to trace the tracer's own tests - #12704
daniel-mohedano wants to merge 1 commit into
Conversation
Build a relocated copy of the stock agent that can trace this repository's own test runs with CI Visibility while the tracer under test runs in the same JVMs. Also fix three stock issues found while doing so: TypeFactory resolving a stale schema for the transform target, missing git data in linked worktrees, and per-test coverage recursing through covered defineClass hooks.
This comment has been minimized.
This comment has been minimized.
CI Visibility Test Environment - sbt-scalatestJob Status: 🟢 success
Baseline: median of Tests run to verify that CI Visibility behavior has not regressed in the current PR. |
CI Visibility Test Environment - netflix-zuulJob Status: 🟢 success
Baseline: median of Tests run to verify that CI Visibility behavior has not regressed in the current PR. |
CI Visibility Test Environment - nebula-release-pluginJob Status: 🟢 success
Baseline: median of Tests run to verify that CI Visibility behavior has not regressed in the current PR. |
CI Visibility Test Environment - heliboardJob Status: 🟢 success
Baseline: median of Tests run to verify that CI Visibility behavior has not regressed in the current PR. |
CI Visibility Test Environment - reactive-streams-jvmJob Status: 🟢 success
Baseline: median of Tests run to verify that CI Visibility behavior has not regressed in the current PR. |
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
CI Visibility Test Environment - pass4sJob Status: 🟢 success
Baseline: median of Tests run to verify that CI Visibility behavior has not regressed in the current PR. |
CI Visibility Test Environment - sonar-kotlinJob Status: 🟢 success
Baseline: median of Tests run to verify that CI Visibility behavior has not regressed in the current PR. |
CI Visibility Test Environment - jolokiaJob Status: 🟢 success
Baseline: median of Tests run to verify that CI Visibility behavior has not regressed in the current PR. |
CI Visibility Test Environment - okhttpJob Status: 🟢 success
Baseline: median of Tests run to verify that CI Visibility behavior has not regressed in the current PR. |
CI Visibility Test Environment - spring_bootJob Status: 🟢 success
Baseline: median of Tests run to verify that CI Visibility behavior has not regressed in the current PR. |
CI Visibility Test Environment - sonar-javaJob Status: 🟢 success
Baseline: median of Tests run to verify that CI Visibility behavior has not regressed in the current PR. |
What Does This Do
Adds an experimental way to trace this repository's own test runs with CI Visibility, while the tracer under test runs in the same JVMs.
./gradlew :dd-java-agent:observerJarbuilds an "observer" agent. It is the stock agent, rewritten offline into a privatedatadog.trace.observernamespace. You attach it to the Gradle daemon with a normal-javaagent, configure it withTRACING_OBSERVER_CONFIG_*variables ortracing.observer.config.*properties, and run tests with-PtraceTracer=true.docs/tracing_the_tracer.mdexplains the setup, configuration, isolation model and limitations.Main changes:
buildSrc, developer-only)Systemproperty, environment andBoolean.getBooleanreads through a private config view. The observer never reads the subject's DD/OTEL settings, config files or propagation headers..inject.datadog.attribute.enabled, DogStatsD client metric names and OTLP attribute names.observerJartask. Not part ofassemble, publishing or ordinary test runs.-PtraceTracer=truerequires an attached observer and tracks its jar and configuration as test inputs. It fails with configuration cache.-javaagent.buildSrcJava sources.TypeFactoryresolves the transform target from the supplied bytes, not a stale cached description. Without this, a later transformer could drop an interface an earlier agent had added. This was reproduced on Mockito'sDetachedThreadLocal, where it aborted a whole retransformation batch..gitas a file, so runs from linked worktrees and submodules get repository, branch and commit tags again.defineClasshook could recurse into aStackOverflowErroron the first recording, and the JVM printedjava.lang.instrument ASSERTION FAILED.Motivation
We want CI Visibility data for dd-trace-java's own test runs, collected by our own tracer, without it interfering with the tracer being tested.
Additional Notes
Compatibility
-PtraceTracer=trueand attach the observer.Tests
buildSrctests cover the rewriter, the runtime and the config sources. The config-source tests compare the stock and relocated config providers on real artifacts. 26/26 pass.TypeFactoryTransformTestpasses, as do the other outline tests: 12/12.UnknownCIInfoTestcase covers a worktree-style.gitfile. The CI Visibilityci,coverage,gitandutilstests pass: 584/584.junit-5.3run with coverage enabled had no assertions, correct git tags, and per-test coverage for all passing tests.Limitations
buildSrc,build-logicand Kotlin DSL accessor builds. Those sessions run no tests but still fetch settings. This is existing stock behavior.TypeFactorychange adds one class-file parse per transformed class and has not been benchmarked.Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issue