5
5
- /docs/java/automatic_instrumentation
6
6
- /docs/languages/java/automatic_instrumentation
7
7
redirects : [{ from: /docs/languages/java/automatic/*, to: ':splat' }]
8
- cSpell:ignore : Dotel myapp
9
8
---
10
9
11
10
Zero-code instrumentation with Java uses a Java agent JAR attached to any Java
@@ -14,97 +13,3 @@ popular libraries and frameworks. It can be used to capture telemetry data at
14
13
the "edges" of an app or service, such as inbound requests, outbound HTTP calls,
15
14
database calls, and so on. To learn how to manually instrument your service or
16
15
app code, see [ Manual instrumentation] ( /docs/languages/java/instrumentation/ ) .
17
-
18
- ## Setup
19
-
20
- 1 . Download [ opentelemetry-javaagent.jar] [ ] from [ Releases] [ ] of the
21
- ` opentelemetry-java-instrumentation ` repository and place the JAR in your
22
- preferred directory. The JAR file contains the agent and instrumentation
23
- libraries.
24
- 2 . Add ` -javaagent:path/to/opentelemetry-javaagent.jar ` and other config to
25
- your JVM startup arguments and launch your app:
26
-
27
- - Directly on the startup command:
28
-
29
- ``` shell
30
- java -javaagent:path/to/opentelemetry-javaagent.jar -Dotel.service.name=your-service-name -jar myapp.jar
31
- ```
32
-
33
- - Via the ` JAVA_TOOL_OPTIONS` and other environment variables:
34
-
35
- ` ` ` shell
36
- export JAVA_TOOL_OPTIONS=" -javaagent:path/to/opentelemetry-javaagent.jar"
37
- export OTEL_SERVICE_NAME=" your-service-name"
38
- java -jar myapp.jar
39
- ` ` `
40
-
41
- # # Configuring the agent
42
-
43
- The agent is highly configurable.
44
-
45
- One option is to pass configuration properties via the ` -D` flag. In this
46
- example, a service name and Zipkin exporter for traces are configured:
47
-
48
- ` ` ` sh
49
- java -javaagent:path/to/opentelemetry-javaagent.jar \
50
- -Dotel.service.name=your-service-name \
51
- -Dotel.traces.exporter=zipkin \
52
- -jar myapp.jar
53
- ` ` `
54
-
55
- You can also use environment variables to configure the agent:
56
-
57
- ` ` ` sh
58
- OTEL_SERVICE_NAME=your-service-name \
59
- OTEL_TRACES_EXPORTER=zipkin \
60
- java -javaagent:path/to/opentelemetry-javaagent.jar \
61
- -jar myapp.jar
62
- ` ` `
63
-
64
- You can also supply a Java properties file and load configuration values from
65
- there:
66
-
67
- ` ` ` sh
68
- java -javaagent:path/to/opentelemetry-javaagent.jar \
69
- -Dotel.javaagent.configuration-file=path/to/properties/file.properties \
70
- -jar myapp.jar
71
- ` ` `
72
-
73
- or
74
-
75
- ` ` ` sh
76
- OTEL_JAVAAGENT_CONFIGURATION_FILE=path/to/properties/file.properties \
77
- java -javaagent:path/to/opentelemetry-javaagent.jar \
78
- -jar myapp.jar
79
- ` ` `
80
-
81
- To see the full range of configuration options, see
82
- [Agent Configuration](configuration).
83
-
84
- # # Supported libraries, frameworks, application services, and JVMs
85
-
86
- The Java agent ships with instrumentation libraries for many popular components.
87
- For the full list, see [Supported libraries, frameworks, application services,
88
- and JVMs][support].
89
-
90
- # # Troubleshooting
91
-
92
- {{% config_option name=" otel.javaagent.debug" %}}
93
-
94
- Set to ` true` to see debug logs. Note that these are quite verbose.
95
-
96
- {{% /config_option %}}
97
-
98
- # # Next steps
99
-
100
- After you have automatic instrumentation configured for your app or service, you
101
- might want to [annotate](annotations) selected methods or add
102
- [manual instrumentation](/docs/languages/java/instrumentation/) to collect
103
- custom telemetry data.
104
-
105
- [opentelemetry-javaagent.jar]:
106
- https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
107
- [releases]:
108
- https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases
109
- [support]:
110
- https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/supported-libraries.md
0 commit comments