All Products
Search
Document Center

Application Real-Time Monitoring Service:Getting Started

Last Updated:Sep 12, 2024

Before you use Managed Service for OpenTelemetry, you must create an Alibaba Cloud account, activate Managed Service for OpenTelemetry, and then obtain the endpoint information. This topic describes how to use the OpenTelemetry Java agent to perform automatic instrumentation on a Java application and report the data of the application. This helps you get started with Managed Service for OpenTelemetry.

Prerequisites

  • An Alibaba Cloud account is created.

  • Managed Service for OpenTelemetry is activated.

Overview

6-新版-调用链详情-中文.jpg

In this example, the OpenTelemetry Java agent is used to perform automatic instrumentation on a Java application and report the data of the application. The following steps are performed:

  1. Download the demo: You can download the demo of the OpenTelemetry Java agent and experience Managed Service for OpenTelemetry. You can also use the OpenTelemetry Java agent to perform automatic instrumentation on your business application and view monitoring data.

  2. Use the OpenTelemetry Java agent to perform automatic instrumentation on an application: You must download the OpenTelemetry Java agent. The OpenTelemetry Java agent allows you to report the data of an application to Managed Service for OpenTelemetry in a non-intrusive manner and can be used to automatically upload trace data in hundreds of Java frameworks. You must also modify the Java virtual machine (JVM) parameters in the Java startup configurations to report trace data.

  3. View monitoring data: You can log on to the Application Real-Time Monitoring Service (ARMS) console to view the monitoring data generated by using OpenTelemetry.

Step 1: Download the demo

You can use the demo of the OpenTelemetry Java agent or your own Java business code.

Download the demo of the OpenTelemetry Java agent.

Note

The demo package contains the following folders:

  • java-agent-usage: uses the OpenTelemetry Java agent to perform automatic instrumentation on an application. In this example, this method is used.

  • otel-sdk-usage: uses OpenTelemetry SDK for Java to manually instrument an application.

  • agent-sdk-usage: uses the OpenTelemetry Java agent and OpenTelemetry SDK for Java to instrument an application.

Step 2: Use the OpenTelemetry Java agent to perform automatic instrumentation on an application

In this example, the OpenTelemetry Java agent is used to perform automatic instrumentation on a Java application and report the data of the application. For more information about the supported Java frameworks, see Supported libraries, frameworks, application servers, and JVMs.

  1. Download the OpenTelemetry Java agent.

    On the download page, find the latest version and click Assets. Find the opentelemetry-javaagent.jar package and download the package.

  2. Modify the JVM parameters in the Java startup configurations to report trace data.

    -javaagent:/{user.workspace}/opentelemetry-javaagent.jar    // Replace {user.workspace} with the directory to which the opentelemetry-javaagent.jar package is downloaded. 
    -Dotel.resource.attributes=service.name=<appName>     // Replace <appName> with the name of the application whose data you want to report to Managed Service for OpenTelemetry. 
    -Dotel.exporter.otlp.headers=Authentication=<token>    // The endpoint information obtained in Prerequisites. 
    -Dotel.exporter.otlp.endpoint=<endpoint>  // The endpoint information obtained in Prerequisites.

    For example, you use the following command to start your application:

    java -jar /{user.workspace}/java-agent-usage-0.0.1-SNAPSHOT.jar

    If you want to report data to Managed Service for OpenTelemetry, use the following command to start your application:

    java -Dotel.resource.attributes=service.name=java-agent-usage-0.0.1-SNAPSHOT -Dotel.exporter.otlp.headers=Authentication=ggxw4l****@7323a5caae30263_ggxw4l****@53df7ad2afe**** -Dotel.exporter.otlp.endpoint=http://tracing-analysis-dc-hz.aliyuncs.com:8090 -javaagent:/{user.workspace}/opentelemetry-javaagent.jar -jar /{user.workspace}/java-agent-usage-0.0.1-SNAPSHOT.jar

Step 3: View monitoring data

  1. Access the demo application by using the following URL: localhost:8081/user/async. The OpenTelemetry Java agent collects data from the demo application and reports the data to Managed Service for OpenTelemetry.

  2. Log on to the ARMS console. In the left-side navigation pane, choose Application Monitoring > Applications. On the Applications page, click the name of the application. On the page that appears, view the trace data.

    Note

    If the image icon is displayed in the Language column, the application is connected to Application Monitoring. If a hyphen (-) is displayed, the application is connected to Managed Service for OpenTelemetry.

    9.jpg

What to do next

After the application data is reported to the Managed Service for OpenTelemetry console, you can perform the following operations in the ARMS console:

You can report the data of applications developed by using different programming languages to the Managed Service for OpenTelemetry console, such as Java, Go, Python, JavaScript, .NET, and C++. The clients that you can use to report data include OpenTelemetry, Jaeger, Zipkin, and SkyWalking.