Skip to content

Commit 88fd9df

Browse files
theletterfchalinsvrnmopentelemetrybot
authored
Add instructions for Java app servers (#3459)
Co-authored-by: Patrice Chalin <[email protected]> Co-authored-by: Severin Neumann <[email protected]> Co-authored-by: opentelemetrybot <[email protected]>
1 parent 14e46b7 commit 88fd9df

File tree

1 file changed

+163
-0
lines changed

1 file changed

+163
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
---
2+
title: Application server configuration
3+
linkTitle: App server config
4+
description: Learn how to define agent paths for Java application servers
5+
weight: 15
6+
cSpell:ignore: asadmin binsetenv binstart Glassfish Payara setenv
7+
---
8+
9+
When instrumenting an app that runs on a Java application server with a Java
10+
agent, you must add the `javaagent` path to the JVM arguments. The way to do
11+
this differs from server to server.
12+
13+
## JBoss EAP / WildFly
14+
15+
You can add the `javaagent` argument at the end of the standalone configuration
16+
file:
17+
18+
{{< tabpane text=true persist=lang >}}
19+
20+
{{% tab header="Linux" lang=Linux %}}
21+
22+
```sh
23+
# Add to standalone.conf
24+
JAVA_OPTS="$JAVA_OPTS -javaagent:/path/to/opentelemetry-javaagent.jar"
25+
```
26+
27+
{{% /tab %}} {{% tab header="Windows" lang=Windows %}}
28+
29+
```bat
30+
rem Add to standalone.conf.bat
31+
set "JAVA_OPTS=%JAVA_OPTS% -javaagent:<Drive>:\path\to\opentelemetry-javaagent.jar"
32+
```
33+
34+
{{% /tab %}} {{< /tabpane >}}
35+
36+
## Jetty
37+
38+
To define the path to the Java agent, use the `-javaagent` argument:
39+
40+
```shell
41+
java -javaagent:/path/to/opentelemetry-javaagent.jar -jar start.jar
42+
```
43+
44+
If you use the `jetty.sh` file to start Jetty, add the following line to the
45+
`\<jetty_home\>/bin/jetty.sh` file:
46+
47+
```shell
48+
JAVA_OPTIONS="${JAVA_OPTIONS} -javaagent:/path/to/opentelemetry-javaagent.jar"
49+
```
50+
51+
If you use the start.ini file to define JVM arguments, add the `javaagent`
52+
argument after the `--exec` option:
53+
54+
```ini
55+
#===========================================================
56+
# Sample Jetty start.ini file
57+
#-----------------------------------------------------------
58+
--exec
59+
-javaagent:/path/to/opentelemetry-javaagent.jar
60+
```
61+
62+
## Glassfish / Payara
63+
64+
Add the path to the Java agent using the `asadmin` tool:
65+
66+
{{< tabpane text=true >}} {{% tab Linux %}}
67+
68+
```sh
69+
<server_install_dir>/bin/asadmin create-jvm-options "-javaagent\:/path/to/opentelemetry-javaagent.jar"
70+
```
71+
72+
{{% /tab %}} {{% tab Windows %}}
73+
74+
```powershell
75+
<server_install_dir>\bin\asadmin.bat create-jvm-options '-javaagent\:<Drive>\:\\path\\to\\opentelemetry-javaagent.jar'
76+
```
77+
78+
{{% /tab %}} {{< /tabpane >}}
79+
80+
You can also add the `-javaagent` argument from the Admin Console. For example:
81+
82+
1. Open the GlassFish Admin Console at <http://localhost:4848>.
83+
2. Go to **Configurations > server-config > JVM Settings**.
84+
3. Select **JVM Options > Add JVM Option**.
85+
4. Enter the path to the agent:
86+
`-javaagent:/path/to/opentelemetry-javaagent.jar`
87+
5. **Save** and restart the server.
88+
89+
Make sure that the domain.xml file in your domain directory contains a
90+
`<jmv-options>` entry for the agent.
91+
92+
## Tomcat / TomEE
93+
94+
Add the path to the Java agent to your startup script:
95+
96+
{{< tabpane text=true persist=lang >}}
97+
98+
{{% tab header="Linux" lang=Linux %}}
99+
100+
```sh
101+
# Add to <tomcat_home>/bin/setenv.sh
102+
CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/opentelemetry-javaagent.jar"
103+
```
104+
105+
{{% /tab %}} {{% tab header="Windows" lang=Windows %}}
106+
107+
```bat
108+
rem Add to <tomcat_home>\bin\setenv.bat
109+
set CATALINA_OPTS=%CATALINA_OPTS% -javaagent:"<Drive>:\path\to\opentelemetry-javaagent.jar"
110+
```
111+
112+
{{% /tab %}} {{< /tabpane >}}
113+
114+
## WebLogic
115+
116+
Add the path to the Java agent to your domain startup script:
117+
118+
{{< tabpane text=true persist=lang >}}
119+
120+
{{% tab header="Linux" lang=Linux %}}
121+
122+
```sh
123+
# Add to <domain_home>/bin/startWebLogic.sh
124+
export JAVA_OPTIONS="$JAVA_OPTIONS -javaagent:/path/to/opentelemetry-javaagent.jar"
125+
```
126+
127+
{{% /tab %}} {{% tab header="Windows" lang=Windows %}}
128+
129+
```bat
130+
rem Add to <domain_home>\bin\startWebLogic.cmd
131+
set JAVA_OPTIONS=%JAVA_OPTIONS% -javaagent:"<Drive>:\path\to\opentelemetry-javaagent.jar"
132+
```
133+
134+
{{% /tab %}} {{< /tabpane >}}
135+
136+
For managed server instances, add the `-javaagent` argument using the admin
137+
console.
138+
139+
## WebSphere Liberty Profile
140+
141+
Add the path to the Java agent to the `jvm.options` file. For a single server,
142+
edit `${server.config.dir}/jvm.options`, and for all servers, edit
143+
`${wlp.install.dir}/etc/jvm.options`:
144+
145+
```ini
146+
-javaagent:/path/to/opentelemetry-javaagent.jar
147+
```
148+
149+
Restart the server after saving the file.
150+
151+
## WebSphere Traditional
152+
153+
Open the WebSphere Admin Console and follow these steps:
154+
155+
<!-- markdownlint-disable blanks-around-fences -->
156+
157+
1. Navigate to **Servers > Server type > WebSphere application servers**.
158+
2. Select the server.
159+
3. Go to **Java and Process Management > Process Definition**.
160+
4. Select **Java Virtual Machine**.
161+
5. In **Generic JVM arguments**, enter the path to the agent:
162+
`-javaagent:/path/to/opentelemetry-javaagent.jar`.
163+
6. Save the configuration and restart the server.

0 commit comments

Comments
 (0)