This product is not supported for your selected Datadog site. ().
このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください

Dynamic Instrumentation is a feature of the Datadog tracing library that lets you add instrumentation to your application at runtime without code changes or redeployments. Follow these instructions to set up Dynamic Instrumentation for Java.

Prerequisites

Before you begin, review the Dynamic Instrumentation prerequisites. Java applications also require:

Installation

  1. If you don’t already have APM enabled, in your Agent configuration, set the DD_APM_ENABLED environment variable to true and listening to the port 8126/TCP.

  2. Download dd-java-agent.jar:

    wget -O dd-java-agent.jar 'https://dtdg.co/latest-java-tracer'
    
    curl -Lo dd-java-agent.jar 'https://dtdg.co/latest-java-tracer'
    
    ADD 'https://dtdg.co/latest-java-tracer' dd-java-agent.jar
    

  3. Run your service with Dynamic Instrumentation enabled by setting -Ddd.dynamic.instrumentation.enabled flag or DD_DYNAMIC_INSTRUMENTATION_ENABLED environment variable to true. Specify dd.service, dd.env, and dd.version Unified Service Tags so you can filter and group your instrumentations and target active clients across these dimensions.

    Example service startup command:

    java \
        -javaagent:dd-java-agent.jar \
        -Ddd.service=<YOUR_SERVICE> \
        -Ddd.env=<YOUR_ENVIRONMENT> \
        -Ddd.version=<YOUR_VERSION> \
        -Ddd.dynamic.instrumentation.enabled=true \
        -jar <YOUR_SERVICE>.jar <YOUR_SERVICE_FLAGS>
    
    export DD_SERVICE=<YOUR_SERVICE>
    export DD_ENV=<YOUR_ENV>
    export DD_VERSION=<YOUR_VERSION>
    export DD_DYNAMIC_INSTRUMENTATION_ENABLED=true
    java \
        -javaagent:dd-java-agent.jar \
        -jar <YOUR_SERVICE>.jar <YOUR_SERVICE_FLAGS>
    

    Note: The -javaagent argument needs to be before -jar, adding it as a JVM option rather than an application argument. For more information, see the Oracle documentation:

    # Good:
    java -javaagent:dd-java-agent.jar ... -jar my-service.jar -more-flags
    # Bad:
    java -jar my-service.jar -javaagent:dd-java-agent.jar ...
    
  4. After starting your service with Dynamic Instrumentation enabled, you can start using Dynamic Instrumentation on the APM > Dynamic Instrumentation page.

Configuration

Configure Dynamic Instrumentation using the following environment variables:

Environment variableTypeDescription
DD_DYNAMIC_INSTRUMENTATION_ENABLEDBooleanAlternate for -Ddd.dynamic.instrumentation.enabled argument. Set to true to enable Dynamic Instrumentation.
DD_SERVICEStringThe service name, for example, web-backend.
DD_ENVStringThe environment name, for example, production.
DD_VERSIONStringThe version of your service.
DD_TAGSStringTags to apply to produced data. Must be a list of <key>:<value> separated by commas such as: layer:api,team:intake.

What to do next

See Dynamic Instrumentation for information about adding instrumentations and browsing and indexing the data.

Limitations

  • On JDK 18 and below, classes compiled with the -parameters flag may fail to instrument with the error message “Method Parameters detected”. Spring 6+, Spring Boot 3+, and Scala use this flag by default.

Further reading

お役に立つドキュメント、リンクや記事: