MSE Java agent compatibility with other agents

更新时间:
复制 MD 格式

In the microservices model, various performance monitoring or governance tools, such as application performance management (APM) tools, tracing analysis tools, and security scanning tools, are used in most cases. Each tool may require its own Java agent. However, if multiple agents coexist, compatibility issues primarily arise from bytecode injection conflicts and resource competition. This topic describes the compatibility issues between MSE Java agent and other mainstream agents and provides solutions to these issues.

Overview

Like other mainstream agents, MSE Java agent uses frameworks such as Service Mesh (ASM) to instrument bytecode without modifying code. If you install two agents on your application, your code is instrumented twice. Code instrumentation methods vary with vendors, which may cause code conflicts. As a result, various issues, such as slow application startup and feature failures, may occur. Therefore, we recommend that you do not install multiple agents on your application. In some scenarios, you have to install two agents on an application due to special requirements or during a migration transition period. To adapt to these scenarios, Alibaba Cloud conducts a large number of agent compatibility tests on MSE to improve agent compatibility. However, if multiple agents coexist, there is still a possibility that conflicts or performance degradation issues occur when the agents perform bytecode enhancements on a plug-in. Therefore, long-term coexistence of multiple agents is not recommended.

Note

If you use MSE together with Application Real-Time Monitoring Service (ARMS), we recommend that you follow instructions in Is the ARMS agent compatible with other APM agents such as SkyWalking?

OpenTelemetry

MSE Java agent of version 4.x or later is built on top of OpenTelemetry. Therefore, if you use open source OpenTelemetry together with MSE Java agent, the agent that is installed first takes effect, and the other agent is no longer loaded. You must make sure that MSE Java agent is installed first.

SkyWalking

The cache mechanism of SkyWalking may cause agent compatibility issues. As a result, some capabilities provided by MSE Java agent become unavailable. We recommend that you add the following parameters to the Java startup command to disable the SkyWalking cache mechanism. For more information, see SkyWalking official documentation.

-Dskywalking.agent.is_cache_enhanced_class=true -Dskywalking.agent.class_cache_mode=MEMORY  

If you encounter issues, such as startup errors or business request errors, during application startup or runtime after you add the preceding parameters, you can adjust the agent installation order and then restart your application. For the recommended method to adjust the agent installation order, see Other APM agents (including TTL agent and Pinpoint).

Other APM agents (including TTL agent and Pinpoint)

If you encounter issues during application startup or runtime when you install MSE Java agent with another open source APM agent, such as TTL agent or Pinpoint, you can try to resolve the issues by adjusting the agent installation order. For example, if you use MSE Java agent together with the TransmittableThreadLocal agent, you can adjust the agent installation order by using one of the following methods.

  • Adjust startup parameters for manual agent installation: If agents are manually installed, you can adjust the installation order of open source TTL agent and MSE Java agent in the access script to ensure that MSE Java agent is installed after the TTL agent.

    Sample parameters for a Spring Boot application:

    -javaagent:/home/admin/transmittable-thread-local-2.14.2.jar -javaagent:/{user.workspace}/AliyunJavaAgent/aliyun-java-agent.jar
  • Add Java virtual machine (JVM) parameters for automatic agent installation: If agents are automatically installed in a Container Service for Kubernetes (ACK) cluster, you can add JVM parameters in the ACK console instead of script modifications.

    1. Log on to the ACK console.

    2. In the left-side navigation pane, click Clusters. Then, click the name of the cluster that you want to manage.

    3. In the left-side navigation pane, choose Workloads > Deployments.

    4. On the Deployments page, find the application connected to MSE and click Edit in the Actions column.

    5. Add the TTL agent parameter to Environment Variable, and click Update.

      Set Type to Custom, Variable name to JAVA_TOOL_OPTIONS, and Variable/value reference to -javaagent:/home/admin/transmittable-thread-local-2.14.2.jar.

Encryption agents

If you use bytecode encryption tools to encrypt bytecode, the following agent requirements must be met. Otherwise, application startup failures may occur after MSE Java agent is installed on your application.