OpenTelemetry auto-instrumentation and instrumentation libraries for Java
Go to file
renovate[bot] 6af7676b51
fix(deps): update dependency org.springframework.boot:spring-boot-starter-web to v3.4.6 (#13902)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-22 17:01:38 +03:00
.githooks Use Spotless for formatting (DataDog/dd-trace-java#1619) 2020-06-30 11:15:48 -07:00
.github Auto license report (#13886) 2025-05-21 10:14:54 +03:00
benchmark-jfr-analyzer Remove unshaded javax.annotation classes from bootstrap class loader (#4454) 2021-10-21 14:47:50 -07:00
benchmark-overhead chore(deps): update weekly update (#13875) 2025-05-19 07:50:43 +03:00
benchmark-overhead-jmh fix(deps): update dependency org.springframework.boot:spring-boot-starter-web to v3.4.6 (#13902) 2025-05-22 17:01:38 +03:00
bom fix(deps): update dependency io.opentelemetry.semconv:opentelemetry-semconv to v1.30.0-rc.1 (#13116) 2025-01-30 14:18:43 -08:00
bom-alpha fix(deps): update dependency io.opentelemetry.semconv:opentelemetry-semconv to v1.30.0-rc.1 (#13116) 2025-01-30 14:18:43 -08:00
buildscripts Instrument bedrock InvokeModelWithResponseStream (#13607) 2025-04-09 10:22:39 -07:00
conventions fix(deps): update dependency checkstyle to v10.24.0 (#13898) 2025-05-22 08:35:02 +03:00
custom-checks Run tests with jdk24 and 25-ea (#13824) 2025-05-09 08:24:34 -07:00
dependencyManagement fix(deps): update dependency io.opentelemetry.proto:opentelemetry-proto to v1.7.0-alpha (#13899) 2025-05-22 14:34:18 +03:00
docs Remove space in references to OpenTelemetry (#13901) 2025-05-22 06:13:30 -07:00
examples fix(deps): update dependency io.opentelemetry.proto:opentelemetry-proto to v1.7.0-alpha (#13899) 2025-05-22 14:34:18 +03:00
gradle/wrapper chore(deps): update dependency gradle to v8.14 (#13773) 2025-04-25 15:01:45 +03:00
gradle-plugins chore(deps): update plugin org.gradle.toolchains.foojay-resolver-convention to v1 (#13878) 2025-05-19 15:29:28 -07:00
instrumentation Remove space in references to OpenTelemetry (#13901) 2025-05-22 06:13:30 -07:00
instrumentation-annotations Add @WithSpan option to break from existing context (#13112) 2025-03-13 19:15:44 +00:00
instrumentation-annotations-support Fix typo (#11672) 2024-06-27 09:14:22 +03:00
instrumentation-annotations-support-testing fix(deps): update dependency io.opentelemetry.semconv:opentelemetry-semconv to v1.30.0-rc.1 (#13116) 2025-01-30 14:18:43 -08:00
instrumentation-api Don't cache sanitization results for large sql statements (#13353) 2025-04-10 12:12:55 -07:00
instrumentation-api-incubator Added JDBC db.query.parameter span attributes (#13719) 2025-05-14 17:52:22 +03:00
instrumentation-docs Add more metadata descriptions, configs, and fix NPE in jdbc (#13854) 2025-05-15 15:21:13 +03:00
javaagent Update the OpenTelemetry SDK version to 1.50.0 (#13834) 2025-05-15 10:03:44 -07:00
javaagent-bootstrap Update the OpenTelemetry SDK version to 1.50.0 (#13834) 2025-05-15 10:03:44 -07:00
javaagent-extension-api Update the OpenTelemetry SDK version to 1.50.0 (#13834) 2025-05-15 10:03:44 -07:00
javaagent-internal-logging-application Fix flaky application logging test (#9341) 2023-08-30 10:46:16 +00:00
javaagent-internal-logging-simple Update shadow plugin to new version and coordinates (#11979) 2024-08-09 09:40:04 +03:00
javaagent-tooling Run tests with jdk24 and 25-ea (#13824) 2025-05-09 08:24:34 -07:00
licenses Update the OpenTelemetry SDK version to 1.50.0 (#13834) 2025-05-15 10:03:44 -07:00
muzzle Allow advice to define custom mappings (#13751) 2025-04-23 08:19:38 +03:00
opentelemetry-api-shaded-for-instrumenting Update the OpenTelemetry SDK version to 1.50.0 (#13834) 2025-05-15 10:03:44 -07:00
opentelemetry-ext-annotations-shaded-for-instrumenting Update shadow plugin to new version and coordinates (#11979) 2024-08-09 09:40:04 +03:00
opentelemetry-instrumentation-annotations-shaded-for-instrumenting Update shadow plugin to new version and coordinates (#11979) 2024-08-09 09:40:04 +03:00
opentelemetry-instrumentation-api-shaded-for-instrumenting Update shadow plugin to new version and coordinates (#11979) 2024-08-09 09:40:04 +03:00
sdk-autoconfigure-support add Cloud foundry resource provider (#13782) 2025-05-06 09:49:47 +03:00
smoke-tests chore(deps): update weekly update (#13875) 2025-05-19 07:50:43 +03:00
smoke-tests-otel-starter Remove guava dependency from testing-common (#13676) 2025-04-09 07:05:45 -07:00
test-report fix(deps): update dependency com.google.apis:google-api-services-sheets to v4-rev20250513-2.0.0 (#13892) 2025-05-21 15:22:37 +03:00
testing fix(deps): update armeria packages to v1.32.5 (patch) (#13715) 2025-04-16 10:59:19 +03:00
testing-common Update the OpenTelemetry SDK version to 1.50.0 (#13834) 2025-05-15 10:03:44 -07:00
.clomonitor.yml Remove one badge (#13277) 2025-02-12 09:31:36 +02:00
.editorconfig Bump spotless-plugin-gradle from 6.12.1 to 6.13.0 (#7591) 2023-01-17 19:43:46 -08:00
.fossa.yml Update the OpenTelemetry SDK version to 1.50.0 (#13834) 2025-05-15 10:03:44 -07:00
.gitattributes Add task to generate license report into licenses folder. (#2239) 2021-02-12 17:20:08 +09:00
.gitignore ci: use .java-version (#11323) 2024-05-15 07:31:25 -07:00
.java-version ci: use .java-version (#11323) 2024-05-15 07:31:25 -07:00
CHANGELOG.md Update version to 2.17.0-SNAPSHOT (#13861) 2025-05-15 21:32:35 +00:00
CONTRIBUTING.md Update docs for running tests (#12987) 2025-01-07 13:02:14 -08:00
ISSUES.md Issue label update (#9292) 2023-08-24 12:53:54 +03:00
LICENSE Update to standard LICENSE file for OpenTelemetry (#19) 2019-11-19 09:46:10 -08:00
README.md Remove note about 1.x releases (#13849) 2025-05-14 07:51:45 +03:00
RELEASING.md Update everywhere to use new otelbot github app (#13256) 2025-02-10 05:17:12 -08:00
VERSIONING.md Apply Prettier to markdown files (#8968) 2023-07-19 12:22:35 -07:00
build.gradle.kts Add FOSSA license scanning (#13257) 2025-02-11 06:00:33 -08:00
code-of-conduct.md Add code-of-conduct file. (#2341) 2021-02-19 16:24:41 +09:00
gradle.properties Remove deprecated gradle system property (#13680) 2025-04-09 18:59:12 -07:00
gradlew chore(deps): update dependency gradle to v8.14 (#13773) 2025-04-25 15:01:45 +03:00
gradlew.bat chore(deps): update dependency gradle to v8.14 (#13773) 2025-04-25 15:01:45 +03:00
settings.gradle.kts chore(deps): update plugin org.gradle.toolchains.foojay-resolver-convention to v1 (#13878) 2025-05-19 15:29:28 -07:00
version.gradle.kts Update version to 2.17.0-SNAPSHOT (#13861) 2025-05-15 21:32:35 +00:00

README.md

OpenTelemetry Instrumentation for Java

Release OpenSSF Scorecard Slack

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.

This repository also publishes standalone instrumentation for several libraries (and growing) that can be used if you prefer that over using the Java agent. Please see the standalone library instrumentation column on Supported Libraries. If you are looking for documentation on using those.

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.jar \
     -jar myapp.jar

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

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

java -javaagent:path/to/opentelemetry-javaagent.jar \
     -Dotel.resource.attributes=service.name=your-service-name \
     -Dotel.traces.exporter=zipkin \
     -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.

For a detailed list of agent configuration options, see the agent configuration docs.

For a detailed list of additional SDK configuration environment variables and system properties, see the SDK configuration docs.

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.

Creating agent extensions

Extensions add new features and capabilities to the agent without having to create a separate distribution or to fork this repository. For example, you can create custom samplers or span exporters, set new defaults, and embed it all in the agent to obtain a single jar file.

Creating an agent distribution

Distribution provides guidance on creating a separate distribution, serving as a collection of examples for extending the functionality of the OpenTelemetry Java instrumentation agent. It also demonstrates how to repackage the agent while incorporating custom features. Agent extensions are recommended instead for most users as they are simpler and do not require rebuilding with each OpenTelemetry Java agent release.

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.

For detailed instructions, see Manual instrumentation.

Logger MDC (Mapped Diagnostic Context) auto-instrumentation

It is possible to inject trace information like trace IDs and span IDs into your custom application logs. For details, 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.

Contributing

See CONTRIBUTING.md.

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

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

Emeritus maintainers:

Learn more about roles in the community repository.

Thanks to all the people who have already contributed!