OpenTelemetry auto-instrumentation and instrumentation libraries for Java
Go to file
Lauri Tulmin 12cbfe953b
Rework lettuce argument splitter regex (#13736)
2025-04-22 07:44:54 -07:00
.githooks
.github Fix link exclusion (#13723) 2025-04-16 17:36:26 -07:00
benchmark-jfr-analyzer
benchmark-overhead chore(deps): update weekly update (#13744) 2025-04-21 09:33:08 +03:00
benchmark-overhead-jmh fix(deps): update dependency org.springframework.boot:spring-boot-starter-web to v3.4.4 (#13565) 2025-03-21 13:04:03 +02: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 errorproneversion to v2.38.0 (minor) (#13738) 2025-04-21 09:12:19 -07:00
custom-checks fix(deps): update errorproneversion to v2.37.0 (minor) (#13552) 2025-03-27 20:05:38 +02:00
dependencyManagement fix(deps): update errorproneversion to v2.38.0 (minor) (#13738) 2025-04-21 09:12:19 -07:00
docs Add descriptions for modules related to custom instrumentation (#13704) 2025-04-14 13:47:50 -07:00
examples fix(deps): update junit5 monorepo to v5.12.2 (patch) (#13699) 2025-04-14 08:11:45 +03:00
gradle/wrapper chore(deps): update dependency gradle to v8.13 (#13394) 2025-02-25 22:22:55 +02:00
gradle-plugins fix(deps): update guava packages to v33.4.8-jre (patch) (#13710) 2025-04-15 07:25:05 +03:00
instrumentation Rework lettuce argument splitter regex (#13736) 2025-04-22 07:44:54 -07:00
instrumentation-annotations Add @WithSpan option to break from existing context (#13112) 2025-03-13 19:15:44 +00:00
instrumentation-annotations-support
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 Don't cache sanitization results for large sql statements (#13353) 2025-04-10 12:12:55 -07:00
instrumentation-docs fix(deps): update errorproneversion to v2.38.0 (minor) (#13738) 2025-04-21 09:12:19 -07:00
javaagent Add all otel api bridging instrumentations to testing agent (#13423) 2025-02-28 19:10:26 +02:00
javaagent-bootstrap support dynamic attach (#13499) 2025-03-27 09:38:49 +02:00
javaagent-extension-api Add an option to mark indy converted instrumentations (#13665) 2025-04-09 20:03:45 -07:00
javaagent-internal-logging-application
javaagent-internal-logging-simple
javaagent-tooling Verify that there are no VirtualField.find calls in indy ready advice (#13689) 2025-04-11 06:33:17 -07:00
licenses fix(deps): update opentelemetry-java-contrib monorepo to v1.46.0-alpha (minor) (#13700) 2025-04-14 16:58:24 +00:00
muzzle Fix typo in comment (#13662) 2025-04-07 16:46:50 +03:00
opentelemetry-api-shaded-for-instrumenting Update the OpenTelemetry SDK version to 1.47.0 (#13250) 2025-02-12 16:14:27 -08:00
opentelemetry-ext-annotations-shaded-for-instrumenting
opentelemetry-instrumentation-annotations-shaded-for-instrumenting
opentelemetry-instrumentation-api-shaded-for-instrumenting
sdk-autoconfigure-support add azure resource provider like gcp and aws (#13627) 2025-04-02 09:32:37 +03:00
smoke-tests chore(deps): update weekly update (#13744) 2025-04-21 09:33:08 +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 errorproneversion to v2.37.0 (minor) (#13552) 2025-03-27 20:05:38 +02:00
testing fix(deps): update armeria packages to v1.32.5 (patch) (#13715) 2025-04-16 10:59:19 +03:00
testing-common Remove guava dependency from testing-common (#13676) 2025-04-09 07:05:45 -07:00
.clomonitor.yml Remove one badge (#13277) 2025-02-12 09:31:36 +02:00
.editorconfig
.fossa.yml Move tomcat-jdbc into a javaagent folder (#13567) 2025-03-21 12:20:38 +00:00
.gitattributes
.gitignore
.java-version
CHANGELOG.md Update version to 2.16.0-SNAPSHOT (#13693) 2025-04-10 20:53:31 +00:00
CONTRIBUTING.md
ISSUES.md
LICENSE
README.md Improved grammar (#13694) 2025-04-11 02:21:46 +00:00
RELEASING.md Update everywhere to use new otelbot github app (#13256) 2025-02-10 05:17:12 -08:00
VERSIONING.md
build.gradle.kts Add FOSSA license scanning (#13257) 2025-02-11 06:00:33 -08:00
code-of-conduct.md
gradle.properties Remove deprecated gradle system property (#13680) 2025-04-09 18:59:12 -07:00
gradlew chore(deps): update dependency gradle to v8.13 (#13394) 2025-02-25 22:22:55 +02:00
gradlew.bat
settings.gradle.kts chore(deps): update plugin org.gradle.toolchains.foojay-resolver-convention to v0.10.0 (#13688) 2025-04-10 14:07:51 +03:00
version.gradle.kts Update version to 2.16.0-SNAPSHOT (#13693) 2025-04-10 20:53:31 +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.

Note: There are 2.x releases and 1.x releases. The 2.0 release included significant breaking changes, the details of which can be found in the release notes. It is recommended to use the latest 2.x release which will have the latest features and improvements. 1.x will receive security patches for a limited time and will not include other bug fixes and enhancements.

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!