Skip to content

Commit 2c92a06

Browse files
authored
Document self-test command
1 parent d5b5962 commit 2c92a06

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ This agent can either be attached when the process is started, or attached later
3535

3636
In each case, the agent must be configured with the proxy host (e.g. 127.0.0.1), the proxy port (e.g. 8000) and the absolute path to the HTTPS certificate to be trusted.
3737

38+
### Attaching at startup
39+
3840
To attach at startup, pass this JAR using the `javaagent` option, e.g:
3941

4042
```
4143
java -javaagent:./agent.jar=127.0.0.1|8000|/path/to/cert.pem -jar ./application.jar
4244
```
4345

46+
### Attaching to a running process
47+
4448
To attach to a process, first launch the target process, and then run:
4549

4650
```
@@ -59,4 +63,14 @@ You can also query the available JVM processes ids, like so:
5963
413868:org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.7
6064
```
6165

62-
When attached from startup all clients will always be intercepted. When attached later, both newly created HTTP clients and already existing instances will be intercepted, but it's possible that in some cases already established connections may not be immediately captured. Typically though these will eventually close and be reconnected, and at that point the connection is always intercepted.
66+
When attached from startup all clients will always be intercepted. When attached later, both newly created HTTP clients and already existing instances will be intercepted, but it's possible that in some cases already established connections may not be immediately captured. Typically though these will eventually close and be reconnected, and at that point the connection is always intercepted.
67+
68+
### Testing attachment capabilities
69+
70+
Not all JDKs provide the instrumentation & attachment APIs required to support this process, although all Oracle & OpenJDK v9+ versions should do so.
71+
72+
To check this, you can test whether the `java` in your $PATH is capable of attaching to and intercepting a target process using the self-test command, like so:
73+
74+
```bash
75+
java -Djdk.attach.allowAttachSelf=true -jar ./agent.jar self-test
76+
```

0 commit comments

Comments
 (0)