Skip to content

Commit 3a81c80

Browse files
docs: add application server setup and JAVA_TOOL_OPTIONS scope warning (#1059)
* add application server setup guidance and JAVA_TOOL_OPTIONS scope warning
1 parent b5bffb6 commit 3a81c80

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

docs/reference/edot-java/setup/index.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ For Kubernetes, use the OTel Kubernetes Operator. The Operator also manages the
2727

2828
## Runtime attach
2929

30-
For environments where modifying the JVM arguments or configuration is not possible, or when including the EDOT Java in the application binary is necessary or preferred, use the [runtime attach](/reference/edot-java/setup/runtime-attach.md) setup option.
30+
For environments where modifying the JVM arguments or configuration is impossible, or when including the EDOT Java in the application binary is necessary or preferred, use the [runtime attach](/reference/edot-java/setup/runtime-attach.md) setup option.
3131

3232
## All other environments
3333

@@ -94,9 +94,31 @@ java \
9494
-jar myapp.jar
9595
```
9696

97-
When modifying the JVM command line arguments is not possible, use the `JAVA_TOOL_OPTIONS` environment variable to provide the `-javaagent:` argument or JVM system properties. When `JAVA_TOOL_OPTIONS` is set, all JVMs automatically use it, so make sure to limit the scope to the relevant JVMs.
97+
When modifying the JVM command line arguments is not possible, use the `JAVA_TOOL_OPTIONS` environment variable to provide the `-javaagent:` argument or JVM system properties:
9898

99-
Some application servers require manual steps or modification of their configuration files. Refer to [dedicated instructions](https://opentelemetry.io/docs/zero-code/java/agent/server-config/) for more details.
99+
```sh
100+
export JAVA_TOOL_OPTIONS="-javaagent:/path/to/agent.jar"
101+
```
102+
103+
:::{note}
104+
`JAVA_TOOL_OPTIONS` is applied to every JVM process that starts in the same environment, including helper processes, build tools, or other services sharing a host or container. In application server deployments or Kubernetes pods that run multiple JVM processes, this can result in unintended instrumentation of JVMs you did not mean to instrument.
105+
106+
To avoid this, prefer setting `-javaagent` directly in the server-specific startup script (refer to [Application servers](#application-servers)) rather than using `JAVA_TOOL_OPTIONS` at a system or pod level.
107+
:::
108+
109+
### Application servers
110+
111+
Many application servers require adding the `-javaagent` argument to a server-specific configuration file rather than the process command line. The following table summarizes where to add the argument for common servers. For full details, refer to the [contrib OpenTelemetry instructions](https://opentelemetry.io/docs/zero-code/java/agent/server-config/).
112+
113+
| Server | Where to add `-javaagent` |
114+
|---|---|
115+
| **Tomcat / TomEE** | set `CATALINA_OPTS` in `bin/setenv.sh` (Linux) or `bin/setenv.bat` (Windows) — create the file if it doesn't exist |
116+
| **JBoss EAP / WildFly** | `bin/standalone.conf` (Linux) or `bin/standalone.conf.bat` (Windows) — add to `JAVA_OPTS` |
117+
| **Jetty** | `bin/jetty.sh` (`JAVA_OPTIONS`), `start.ini`, or pass directly to `java -jar start.jar` |
118+
| **WebLogic** | `bin/startWebLogic.sh` (Linux) or `bin/startWebLogic.cmd` (Windows) — add to `JAVA_OPTIONS` |
119+
| **Glassfish / Payara** | `asadmin create-jvm-options` command, or Admin Console → JVM Settings |
120+
| **WebSphere Liberty** | `jvm.options` file (server-specific or global) |
121+
| **WebSphere Traditional** | Admin Console → Servers → Application Servers → *server* → Java and Process Management → Process Definition → Java Virtual Machine → Generic JVM arguments |
100122

101123
For applications deployed with Kubernetes, use the [OpenTelemetry Operator](/reference/edot-java/setup/k8s.md).
102124

0 commit comments

Comments
 (0)