java agent代码

Anuraag Agrawal 66f5554a2b Mark all non-javaagent artifacts as -alpha version. (#2286) 4 years ago
.githooks 4a943c8411 Use Spotless for formatting (DataDog/dd-trace-java#1619) 4 years ago
.github a8676e2bc8 Create draft release with uploaded agent in github workflow. (#2237) 4 years ago
benchmark 723a08ac4f Fix references of otel.trace. to otel.traces. (#2269) 4 years ago
benchmark-e2e 5bf9f34caa Bring org.testcontainers to 1.15.1 (#2178) 4 years ago
benchmark-integration afdde0355b Update to OTel 0.14.1 (#2059) 4 years ago
buildSrc 2d683d4289 No more gradle warnings (#2103) 4 years ago
docs 5d8464305e writing-instrumentation.md: Fix section hierarchy (#2287) 4 years ago
examples 39e194a61f examples/distro: Update to newest released versions, fix build. (#2290) 4 years ago
gradle 66f5554a2b Mark all non-javaagent artifacts as -alpha version. (#2286) 4 years ago
instrumentation f866bf2f93 Remove unused gradle config (#2268) 4 years ago
instrumentation-api a74f60b3f8 Add JUnit 5 extensions for instrumentation testing (#2241) 4 years ago
instrumentation-core a74f60b3f8 Add JUnit 5 extensions for instrumentation testing (#2241) 4 years ago
javaagent 66f5554a2b Mark all non-javaagent artifacts as -alpha version. (#2286) 4 years ago
javaagent-api a74f60b3f8 Add JUnit 5 extensions for instrumentation testing (#2241) 4 years ago
javaagent-bootstrap a74f60b3f8 Add JUnit 5 extensions for instrumentation testing (#2241) 4 years ago
javaagent-spi 723a08ac4f Fix references of otel.trace. to otel.traces. (#2269) 4 years ago
javaagent-tooling adc24352cb Updates to dependencies included in license report (#2278) 4 years ago
licenses adc24352cb Updates to dependencies included in license report (#2278) 4 years ago
load-generator afdde0355b Update to OTel 0.14.1 (#2059) 4 years ago
opentelemetry-api-shaded-for-instrumenting afdde0355b Update to OTel 0.14.1 (#2059) 4 years ago
opentelemetry-ext-annotations-shaded-for-instrumenting a3d11c0262 Rename auto annotations to ext annotations (#1799) 4 years ago
smoke-tests 5dc2cd420a Start smoke test backend and collector only once (#2249) 4 years ago
testing 723a08ac4f Fix references of otel.trace. to otel.traces. (#2269) 4 years ago
testing-common 0adeb85f43 Refactor InMemoryExporter and move some of its methods … (#2264) 4 years ago
.editorconfig 21a1c65128 Remove inner class imports; avoid future imports by disabling in editorconfig (#1489) 4 years ago
.gitattributes 1d4c150111 Add task to generate license report into licenses folder. (#2239) 4 years ago
.gitignore a6e0e27ad4 Remove usage of Contexts from grpc instrumentation. (#1426) 4 years ago
CONTRIBUTING.md f738a158c2 fix the branch master to main (#2225) 4 years ago
LICENSE f2f89a5e22 Update to standard LICENSE file for OpenTelemetry (#19) 5 years ago
README.md 37f17317a2 Add new triager @breedx-splk (#2267) 4 years ago
RELEASING.md 640a7d624b Correct some spelling mistakes (#2025) 4 years ago
build.gradle d7183ebbdc Add a simple description to POM. (#1857) 4 years ago
gradle.properties 2d683d4289 No more gradle warnings (#2103) 4 years ago
gradlew 9cd2d627ca Upgrade to Gradle 6.6 (#1073) 4 years ago
gradlew.bat 9cd2d627ca Upgrade to Gradle 6.6 (#1073) 4 years ago
settings.gradle eaa973c208 Test jax-rs on wildfly (#2242) 4 years ago

README.md


Getting Started   •   Getting Involved   •   Getting In Touch

Build Status GitHub release (latest by date including pre-releases) Beta

Contributing   •   Scope   •   Roadmap


OpenTelemetry Icon OpenTelemetry Instrumentation for Java

About

This project provides a Java agent JAR that can be attached to any Java 8+ application and dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks. You can export the telemetry data in a variety of formats. You can also configure the agent and exporter via command line arguments or environment variables. The net result is the ability to gather telemetry data from a Java application without code changes.

Getting Started

Download the latest version.

This package includes the instrumentation agent as well as instrumentations for all supported libraries and all available data exporters. The package provides a completely automatic, out-of-the-box experience.

Enable the instrumentation agent using the -javaagent flag to the JVM.

java -javaagent:path/to/opentelemetry-javaagent-all.jar \
     -jar myapp.jar

By default, the OpenTelemetry Java agent uses OTLP exporter configured to send data to OpenTelemetry collector at http://localhost:4317.

Configuration parameters are passed as Java system properties (-D flags) or as environment variables. See below for a full list of environment variables. For example:

java -javaagent:path/to/opentelemetry-javaagent-all.jar \
     -Dotel.traces.exporter=zipkin \
     -jar myapp.jar

Specify the external exporter JAR file using the otel.exporter.jar system property:

java -javaagent:path/to/opentelemetry-javaagent-all.jar \
     -Dotel.exporter.jar=path/to/external-exporter.jar \
     -jar myapp.jar

Configuring the Agent

The agent is highly configurable! Many aspects of the agent's behavior can be configured for your needs, such as exporter choice, exporter config (like where data is sent), trace context propagation headers, and much more.

Click here to see the detailed list of configuration environment variables and system properties.

Note: Config parameter names are very likely to change over time, so please check back here when trying out a new version! Please report any bugs or unexpected behavior you find.

Supported libraries, frameworks, and application servers

We support an impressively huge number of libraries and frameworks and a majority of the most popular application servers...right out of the box! Click here to see the full list and to learn more about disabled instrumentation and how to suppress unwanted instrumentation.

Manually instrumenting

For most users, the out-of-the-box instrumentation is completely sufficient and nothing more has to be done. Sometimes, however, users wish to add attributes to the otherwise automatic spans, or they might want to manually create spans for their own custom code.

See here for detailed instructions.

Logger MDC (Mapped Diagnostic Context) auto-instrumentation

It is possible to inject trace information like trace id and span id into your custom application logs.

See Logger MDC auto-instrumentation

Troubleshooting

To turn on the agent's internal debug logging:

-Dotel.javaagent.debug=true

Note: These logs are extremely verbose. Enable debug logging only when needed. Debug logging negatively impacts the performance of your application.

Roadmap to 1.0 (GA)

See GA Requirements

Contributing

See CONTRIBUTING.md.

Triagers (@open-telemetry/java-instrumentation-triagers):

Approvers (@open-telemetry/java-instrumentation-approvers):

Maintainers (@open-telemetry/java-instrumentation-maintainers):

Learn more about roles in the community repository.

Thanks to all the people who already contributed!