Monitoring Java applications from OpenTelemetry Demo on Instana

You can automatically instrument a Java application with the OpenTelemetry Demo and send metrics and traces to Instana through the Instana agent. You can view these metrics, trace, and logs data on the Instana UI. See the following example for instrumenting a Spring Boot application ('adservice') with the OpenTelemetry collector Java agent:

This ad service provides advertisements based on context keys. If no context keys are provided, the service returns random ads. To get started with the OpenTelemetry integration, see the following sample steps:

Prerequisites

Make sure that Java 17 or later are installed in your system.

If dependencies are missing, install them based on your OS.

Sample integration steps

  1. Clone the OpenTelemetry Demo Repository by running the following commands:

    git clone https://github.com/open-telemetry/opentelemetry-demo.git
    cd opentelemetry-demo/src/ad
    
  2. Build the ad service with Gradle by running the following commands:

    ./gradlew installDist
    

This command creates an executable script src/ad/build/install/oteldemo/bin/Ad.

  1. Run the service locally by using the following commands:

    export AD_PORT=8080 (or any other port if this is already in use)
    export FEATURE_FLAG_GRPC_SERVICE_ADDR=featureflagservice:50053
    ./build/install/opentelemetry-demo-ad/bin/Ad
    
  2. (Optional) Dockerize the service by running the following commands from the root directory of OpenTelemetry Demo:

    docker build --file ./src/ad/Dockerfile ./
    

Checking the metrics in Instana UI

You can see the OpenTelemetry data such as metrics, trace, and log in the Instana UI. For more information, see Viewing the OpenTelemetry metrics data.

Before you start to view the data, you must configure your Instana backend and agent properly to collect data from the service.