@descryy/runtime-orchestrator 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +6 -0
- package/dist/attach-to-running-jvm-process.d.ts +45 -98
- package/dist/attach-to-running-jvm-process.d.ts.map +1 -1
- package/dist/attach-to-running-jvm-process.js +206 -136
- package/dist/attach-to-running-jvm-process.js.map +1 -1
- package/dist/attach-to-running-node-process.d.ts +45 -103
- package/dist/attach-to-running-node-process.d.ts.map +1 -1
- package/dist/attach-to-running-node-process.js +90 -115
- package/dist/attach-to-running-node-process.js.map +1 -1
- package/dist/attach-to-running-process.d.ts +51 -71
- package/dist/attach-to-running-process.d.ts.map +1 -1
- package/dist/attach-to-running-process.js +39 -55
- package/dist/attach-to-running-process.js.map +1 -1
- package/dist/cdp-client.d.ts +8 -18
- package/dist/cdp-client.d.ts.map +1 -1
- package/dist/cdp-client.js +9 -22
- package/dist/cdp-client.js.map +1 -1
- package/dist/cgroup-partial-restriction.d.ts +42 -89
- package/dist/cgroup-partial-restriction.d.ts.map +1 -1
- package/dist/cgroup-partial-restriction.js +44 -91
- package/dist/cgroup-partial-restriction.js.map +1 -1
- package/dist/collector-version.d.ts +3 -8
- package/dist/collector-version.d.ts.map +1 -1
- package/dist/collector-version.js +3 -8
- package/dist/collector-version.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/instrumented-execution.d.ts +30 -73
- package/dist/instrumented-execution.d.ts.map +1 -1
- package/dist/instrumented-execution.js +103 -251
- package/dist/instrumented-execution.js.map +1 -1
- package/dist/jvm-agent/build.d.ts +29 -53
- package/dist/jvm-agent/build.d.ts.map +1 -1
- package/dist/jvm-agent/build.js +34 -61
- package/dist/jvm-agent/build.js.map +1 -1
- package/dist/polling-output-source.d.ts +27 -19
- package/dist/polling-output-source.d.ts.map +1 -1
- package/dist/polling-output-source.js +23 -33
- package/dist/polling-output-source.js.map +1 -1
- package/dist/profile-backend-observation.d.ts +26 -53
- package/dist/profile-backend-observation.d.ts.map +1 -1
- package/dist/profile-backend-observation.js +26 -55
- package/dist/profile-backend-observation.js.map +1 -1
- package/dist/respawn-and-supervise.d.ts +39 -72
- package/dist/respawn-and-supervise.d.ts.map +1 -1
- package/dist/respawn-and-supervise.js +43 -84
- package/dist/respawn-and-supervise.js.map +1 -1
- package/package.json +14 -9
package/LICENSE
ADDED
|
@@ -1,71 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Retroactive attach to an already-running **JVM (Java/Kotlin/…)** process
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* (decisions-inbox) is the short record of what got measured before any of
|
|
6
|
-
* this was written and why the slice below is the honest first one, not a
|
|
7
|
-
* full CDP-equivalent.
|
|
2
|
+
* Retroactive attach to an already-running **JVM (Java/Kotlin/…)** process. Not a
|
|
3
|
+
* full CDP-equivalent; see `RT-attach-to-running-jvm-process.md` (decisions-inbox)
|
|
4
|
+
* for what was measured before this was written.
|
|
8
5
|
*
|
|
9
|
-
* **
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* launch) opens a Unix-domain socket at `.java_pid<pid>` in its temp
|
|
18
|
-
* directory and accepts commands over it. `jcmd`/`jstack`/`VisualVM` all use
|
|
19
|
-
* exactly this. Measured directly here: attached to a plain `java
|
|
20
|
-
* QuietServer` process with no `-agentlib`/`-Djdk.attach` flags of any kind
|
|
21
|
-
* and no restart, confirming this is genuinely retroactive, the same
|
|
22
|
-
* standing Node's `SIGUSR1` slice has.
|
|
6
|
+
* **Mechanism, measured against a live JVM, not assumed from docs.** The JVM has
|
|
7
|
+
* no `SIGUSR1`-equivalent, but ships (since JDK 6) HotSpot Dynamic Attach:
|
|
8
|
+
* `VirtualMachine.attach(pid)` creates `.attach_pid<pid>`, signals `SIGQUIT`, and
|
|
9
|
+
* the target's attach-listener thread (already running in every stock HotSpot
|
|
10
|
+
* JVM, nothing to enable at launch) opens a Unix socket at `.java_pid<pid>` and
|
|
11
|
+
* accepts commands — the same thing `jcmd`/`jstack`/`VisualVM` use. Measured:
|
|
12
|
+
* attached to a plain `java QuietServer` with no special flags and no restart,
|
|
13
|
+
* confirming this is genuinely retroactive.
|
|
23
14
|
*
|
|
24
|
-
* **
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* is not a fixture this module's own test can reuse; see
|
|
37
|
-
* `test/fixtures/jvm-attach/BackgroundThreadThrows.java`, a real thread that
|
|
38
|
-
* throws with nothing catching it, the one shape that first slice could see.
|
|
15
|
+
* **Narrower than CDP.** `VirtualMachine.loadAgent(jar, args)` loads a real Java
|
|
16
|
+
* agent (`Instrumentation`) — more powerful than CDP's remote-debugging protocol
|
|
17
|
+
* in principle, but this slice only uses `Thread.setDefaultUncaughtExceptionHandler`
|
|
18
|
+
* (`jvm-agent/Agent.java`), so it never sees an exception a framework already
|
|
19
|
+
* caught (a try/catch, a servlet error page, `@ExceptionHandler`). RT-201 closed
|
|
20
|
+
* one specific instance of that gap: `Agent.java` also installs a ByteBuddy
|
|
21
|
+
* `ClassFileTransformer` tapping
|
|
22
|
+
* `DispatcherServlet#processHandlerException` — Spring MVC's single stable
|
|
23
|
+
* exception choke point — reported as `"framework-caught-exception"`, parsed
|
|
24
|
+
* below and emitted with `payload.handled === true`. This closes only that one
|
|
25
|
+
* choke point: a catch absorbed inside a `@Service` method, or any non-Spring
|
|
26
|
+
* framework, is still invisible.
|
|
39
27
|
*
|
|
40
|
-
* **
|
|
41
|
-
* `
|
|
42
|
-
*
|
|
43
|
-
* header comment for the full mechanism and what was measured) that taps
|
|
44
|
-
* `org.springframework.web.servlet.DispatcherServlet#processHandlerException`
|
|
45
|
-
* — Spring MVC's single stable choke point for every exception-handling
|
|
46
|
-
* path — and reports what it catches as a `"framework-caught-exception"`
|
|
47
|
-
* event, parsed below as `isFrameworkCaughtExceptionEvent` and emitted as
|
|
48
|
-
* `EXCEPTION` evidence with `payload.handled === true`. **This closes only
|
|
49
|
-
* that one choke point.** A catch that never reaches Spring's dispatcher —
|
|
50
|
-
* absorbed inside a `@Service` method, logged nowhere — is still invisible,
|
|
51
|
-
* and no non-Spring framework is instrumented at all. `Runtime.exceptionThrown`'s
|
|
52
|
-
* CDP-side reach (any throw the debugger is configured to pause on,
|
|
53
|
-
* regardless of framework) still has no equivalent here.
|
|
28
|
+
* **No console-output capture** — `System.out`/`err` aren't intercepted; that's
|
|
29
|
+
* `attachToRunningProcess`'s job for a target already logging to a file.
|
|
30
|
+
* `capabilities()` reports `backendLogAccess` unavailable for that reason.
|
|
54
31
|
*
|
|
55
|
-
* **
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* mechanisms claiming the same evidence. `capabilities()` reports
|
|
60
|
-
* `backendLogAccess` unavailable for that reason, unlike the Node slice.
|
|
61
|
-
*
|
|
62
|
-
* **Launcher is a real JDK tool process, not a library call.** There is no
|
|
63
|
-
* Node/native binding for the Attach API in this repo and none is added —
|
|
64
|
-
* `jvm-agent/build.ts` compiles `Attacher.java` once (cached by mtime, same
|
|
65
|
-
* rule `kotlin-server/build.ts` already uses) and this module spawns it as a
|
|
66
|
-
* short-lived `java` child process, the same "one helper invocation, not a
|
|
67
|
-
* new protocol client" shape `discoverNodeInspectorUrl`'s `process.kill`
|
|
68
|
-
* call has, just through a JDK tool instead of a POSIX signal.
|
|
32
|
+
* **Launcher is a real JDK tool process, not a library call** — no Node/native
|
|
33
|
+
* Attach-API binding exists or is added. `jvm-agent/build.ts` compiles
|
|
34
|
+
* `Attacher.java` once (mtime-cached) and this module spawns it as a short-lived
|
|
35
|
+
* `java` child process.
|
|
69
36
|
*/
|
|
70
37
|
import type { Collector } from "@descryy/runtime-contracts";
|
|
71
38
|
export interface AttachToRunningJvmProcessOptions {
|
|
@@ -78,43 +45,23 @@ export interface AttachToRunningJvmProcessOptions {
|
|
|
78
45
|
/** How often to check the agent's output file for new events. */
|
|
79
46
|
readonly pollIntervalMs?: number;
|
|
80
47
|
/**
|
|
81
|
-
* Repo-relative source roots plus the absolute repo root,
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* from the log-tailing path to this one).
|
|
85
|
-
*
|
|
86
|
-
* ## Why the attach path needed this too, and why it went unnoticed
|
|
87
|
-
*
|
|
88
|
-
* `JvmRuntimeAdapterOptions.sourceRoots` (`@descryy/runtime-adapter-jvm`)
|
|
89
|
-
* already fixed this for evidence produced by `createJvmStackTraceParser`
|
|
90
|
-
* — the JVM prints a bare basename (`ProbeApplication.java`), never a
|
|
91
|
-
* path, so `resolveSymbolNode` correctly refuses to match on it alone
|
|
92
|
-
* (RT-031's identity-proxy rule), and reconstruction from the frame's
|
|
93
|
-
* declaring type is what lets the two sides join. This collector builds
|
|
94
|
-
* its `StackFrame.location` directly from the Java agent's own captured
|
|
95
|
-
* `StackTraceElement` fields (`frameToStackFrame` below) and never went
|
|
96
|
-
* through that parser at all, so it never got the fix — invisible until
|
|
97
|
-
* RT-202, because this mechanism's only fixture before then
|
|
98
|
-
* (`BackgroundThreadThrows.java`) is in the default package, where
|
|
99
|
-
* reconstruction is a no-op regardless (no dot in the declaring type).
|
|
48
|
+
* Repo-relative source roots plus the absolute repo root, so a JVM frame's bare
|
|
49
|
+
* basename can be reconstructed into a repo-relative path graph correlation can
|
|
50
|
+
* join on (RT-202, extending RT-162's fix from the log-tailing path to this one).
|
|
100
51
|
*
|
|
101
|
-
*
|
|
52
|
+
* The JVM prints a bare basename (`ProbeApplication.java`), never a path, so
|
|
53
|
+
* `resolveSymbolNode` refuses to match on it alone (RT-031). This collector builds
|
|
54
|
+
* `StackFrame.location` straight from the agent's captured `StackTraceElement`
|
|
55
|
+
* fields, bypassing `createJvmStackTraceParser` entirely, so RT-162's earlier fix
|
|
56
|
+
* there never reached this path — invisible until RT-202, since this mechanism's
|
|
57
|
+
* only prior fixture was in the default package, where reconstruction is a no-op.
|
|
102
58
|
*
|
|
103
|
-
* `
|
|
104
|
-
*
|
|
105
|
-
* `@descryy/runtime-adapter
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* into this language-agnostic-by-convention module would be a bigger
|
|
110
|
-
* architectural change than this gap warrants, so
|
|
111
|
-
* `reconstructJvmSourcePath` below is a second copy of the exact same
|
|
112
|
-
* algorithm (declaring type + basename + candidate roots + `existsSync`
|
|
113
|
-
* check, discarded rather than fabricated when nothing is on disk) —
|
|
114
|
-
* unlike other duplication this project has measured drifting silently,
|
|
115
|
-
* both copies are tiny, pure, and named after the one behaviour they
|
|
116
|
-
* implement, so a future change to one is easy to notice is missing from
|
|
117
|
-
* the other.
|
|
59
|
+
* `reconstructJvmSourcePath` below is a deliberate second copy of
|
|
60
|
+
* `jvm-stack-trace-parser.ts`'s algorithm, not a shared import: this package
|
|
61
|
+
* never takes a real dependency on any `@descryy/runtime-adapter-*` package
|
|
62
|
+
* (JVM's included), and importing the JVM-specific function here would be a
|
|
63
|
+
* bigger architectural change than this gap warrants. Both copies are tiny,
|
|
64
|
+
* pure, and named after the one behaviour they implement.
|
|
118
65
|
*/
|
|
119
66
|
readonly sourceRoots?: {
|
|
120
67
|
readonly repoRoot: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attach-to-running-jvm-process.d.ts","sourceRoot":"","sources":["../src/attach-to-running-jvm-process.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"attach-to-running-jvm-process.d.ts","sourceRoot":"","sources":["../src/attach-to-running-jvm-process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAyF,MAAM,4BAA4B,CAAC;AAMnJ,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+IAA+I;IAC/I,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,iLAAiL;IACjL,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,iEAAiE;IACjE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE;QACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;KACnC,CAAC;CACH;AAoLD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,gCAAgC,GAAG,SAAS,CA0N9F"}
|