java agent代码

Trask Stalnaker d3790ee546 Update .editorconfig for groovy (#397) il y a 4 ans
.circleci 6d1a58d151 Merge tag 'v0.50.0' into correct-history il y a 4 ans
.github 438e284f7f Move CODEOWNERS to .github (#376) il y a 4 ans
agent-bootstrap 3a4483a0f5 Add support for jTDS driver connection urls for SQL Server (#396) il y a 4 ans
agent-tooling 86748e3f8d Shade j.u.l.Logger and slf4j in exporters (#381) il y a 4 ans
auto-exporters c9cf7ffb61 Make auto-instr work with latest otel-java snapshot (#372) il y a 4 ans
benchmark ddb9988473 Jetty-based benchmark for memory usage (#329) il y a 4 ans
benchmark-integration 1f0cd54fd7 Remove copyright year from license header (#322) il y a 4 ans
buildSrc ce3d764ffa Merge commit '437e0f343dcd66ac344556c03bd340ce791b1fdd' into correct-history il y a 4 ans
buildscripts bae0b7b38c Copy .editorconfig file and relevant sections in CONTRIBUTING.md from otel-java repo (#373) il y a 4 ans
exporter-support 1f0cd54fd7 Remove copyright year from license header (#322) il y a 4 ans
gradle c9cf7ffb61 Make auto-instr work with latest otel-java snapshot (#372) il y a 4 ans
instrumentation 3a4483a0f5 Add support for jTDS driver connection urls for SQL Server (#396) il y a 4 ans
java-agent e54f316b27 Add support for new @WithSpan annotation (#379) il y a 4 ans
load-generator 1f0cd54fd7 Remove copyright year from license header (#322) il y a 4 ans
opentelemetry-api-shaded-for-instrumenting 2e210683fd Update to OpenTelemetry API/SDK 0.3.0 (#286) il y a 5 ans
opentelemetry-sdk-shaded-for-testing cd4a97546e Rename boostrap and tooling modules (#146) il y a 5 ans
smoke-tests 6e1c0436da Clarifications about various test tasks (#358) il y a 4 ans
testing 55211ccd73 Fix sporadic test failure (#386) il y a 4 ans
utils 62e43d3e54 Bring back code coverage verification (#357) il y a 4 ans
.editorconfig d3790ee546 Update .editorconfig for groovy (#397) il y a 4 ans
.gitignore 8ee04d54e9 Merge remote-tracking branch 'datadog/master' into dd-merge il y a 5 ans
CONTRIBUTING.md 67766fd13b Add documentation about java agent structure and related classloaders (#380) il y a 4 ans
LICENSE f2f89a5e22 Update to standard LICENSE file for OpenTelemetry (#19) il y a 5 ans
LICENSE-3rdparty.csv 71d264fd00 Rename package to io.opentelemetry.auto (#54) il y a 5 ans
README.md f964725d96 Add troubleshooting section to README (#382) il y a 4 ans
gradle.properties e6404b5f23 Try doubling the metaspace size to fix check task. il y a 6 ans
gradlew 2c4422aa04 Upgradle to gradle 6.0 il y a 5 ans
gradlew.bat 2870819fa6 Update gradle to 6.3 il y a 5 ans
settings.gradle 6d1a58d151 Merge tag 'v0.50.0' into correct-history il y a 4 ans
trace-java.gradle ca296b92fd Normalize sql statements to elide literal numbers and strings. (#366) il y a 4 ans

README.md

OpenTelemetry Auto-Instrumentation for Java

Introduction

This project provides a Java agent that can be attached to any Java 7+ application and dynamically injects bytecode to capture telemetry from a number of popular libraries and frameworks.

Supported Java libraries and frameworks

Library/Framework Versions
Akka HTTP 10.0+
Apache HttpAsyncClient 4.0+
Apache HttpClient 2.0+
AWS SDK 1.11.x and 2.2.0+
Cassandra Driver 3.0+ (not including 4.x yet)
Couchbase Client 2.0+ (not including 3.x yet)
Dropwizard Views 0.7+
Elasticsearch API 2.0+ (not including 7.x yet)
Elasticsearch REST Client 5.0+
Finatra 2.9+
Geode Client 1.4+
Google HTTP Client 1.19+
Grizzly 2.0+
gRPC 1.5+
Hibernate 3.3+
HttpURLConnection Java 7+
Hystrix 1.4+
java.util.logging Java 7+
JAX-RS 0.5+
JAX-RS Client 2.0+
JDBC Java 7+
Jedis 1.4+
Jetty 8.0+
JMS 1.1+
JSP 2.3+
Kafka 0.11+
Lettuce 4.0+
Log4j 1.1+
Logback 1.0+
MongoDB Drivers 3.3+
Netty 3.8+
OkHttp 3.0+
Play 2.3+ (not including 2.8.x yet)
Play WS 1.0+
RabbitMQ Client 2.7+
Ratpack 1.5+
Reactor 3.1+
Rediscala 1.8+
RMI Java 7+
RxJava 1.0+
Servlet 2.3+
Spark Web Framework 2.3+
Spring Data 1.8+
Spring Scheduling 3.1+
Spring Servlet MVC 3.1+
Spring Webflux 5.0+
Spymemcached 2.12+
Twilio 6.6+

Download and run

Release builds

Download the latest release.

The instrumentation agent is enabled using the -javaagent flag to the JVM. Configuration parameters are passed as Java system properties (-D flags) or as environment variables. This is an example:

java -javaagent:path/to/opentelemetry-auto-<version>.jar \
     -Dota.exporter.jar=path/to/opentelemetry-auto-exporters-jaeger-<version>.jar \
     -Dota.exporter.jaeger.endpoint=localhost:14250 \
     -Dota.exporter.jaeger.service.name=shopping \
     -jar myapp.jar

Snapshot builds

For developers testing code changes before a release is complete, there are snapshot builds of the master branch. When a PR is merged to master, a circleci build is kicked off as a github action which shows up as a github check on the git commit on master branch, i.e. a green checkmark. Clicking on the green checkmark you can view the build_test_deploy workflow and the build job shows the artifacts hosted on circleci. The artifacts will be named like:

libs/exporter-support-<version>-SNAPSHOT.jar
libs/opentelemetry-auto-<version>-SNAPSHOT.jar
libs/opentelemetry-auto-exporters-jaeger-<version>-SNAPSHOT.jar
libs/opentelemetry-auto-exporters-logging-<version>-SNAPSHOT.jar
libs/opentelemetry-auto-exporters-otlp-<version>-SNAPSHOT.jar

Configuration parameters (subject to change!)

System property Environment variable Purpose
ota.exporter.jar OTA_EXPORTER_JAR Path to the exporter fat-jar that you want to use

Available exporters

There are three exporters available under releases.

Jaeger exporter

A simple wrapper for the Jaeger exporter of opentelemetry-java. It currently only supports gRPC as its communications protocol.

System property Environment variable Purpose
ota.exporter.jaeger.endpoint OTA_EXPORTER_JAEGER_ENDPOINT The Jaeger endpoint to connect to. Currently only gRPC is supported.
ota.exporter.jaeger.service.name OTA_EXPORTER_JAEGER_SERVICE_NAME The service name of this JVM instance

OTLP exporter

A simple wrapper for the OTLP exporter of opentelemetry-java.

System property Environment variable Purpose
ota.exporter.otlp.endpoint OTA_EXPORTER_OTLP_ENDPOINT The OTLP endpoint to connect to.

Logging Exporter

The logging exporter simply prints the name of the span along with its attributes to stdout. It is used manly for testing and debugging.

System property Environment variable Purpose
ota.exporter.logging.prefix OTA_EXPORTER_LOGGING_PREFIX An optional string that is printed in front of the span name and attributes.

These 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 may find.

Troubleshooting

To turn on the agent's internal debug logging:

-Dio.opentelemetry.auto.slf4j.simpleLogger.defaultLogLevel=debug

Building from source

Build using Java 8:

gradle assemble

and then you can find the java agent artifact at java-agent/build/lib/opentelemetry-auto-<version>.jar.