edit-icon download-icon

Method tracking

Last Updated: Feb 13, 2018

Overview

EDAS method tracing helps you quickly troubleshoot problems of running applications. Typical use cases include:

  • When you find that it takes a long time to run a service logic, and you want to identify the part of code that causes the time consumption.
  • Applications and services are all running smoothly for most of the time. However, a user reports the problem that service response is extremely slow when a specific parameter is passed. In this case, you may need a mechanism to check the code execution related to a specific parameter in a method.
  • When a method with complex service logic is executed, you want to have a clear view of the logic and time sequence of service calls in details.

EDAS method tracing is designed to meet the preceding requirements without interfering with code or stopping applications.

EDAS method tracing adopts the JVM bytecode enhancement technique when recording the time consumption and sequence during the entire call process of the selected method, enabling you to check the execution sequence while execution is in progress.

Restrictions

If the following restrictions affect your services or troubleshooting, open a ticket to consult with us so that we can improve some restrictions or configure a whitelist.

  1. In principle, only tracing of service-type classes is supported. Therefore, packages are filtered by name before tracing starts.

  2. Sampled output is adopted to prevent excessive logs due to large amout of method calls. The default policy is to output logs on 10 calls per second for the method.

  3. When you exit and then log on to the EDAS console again, or refresh the screen, historical trace records are lost and previously pulled tracing information is no longer retained.

  4. Automatic stop policy: If method tracing is in inactive state for 10 minutes, EDAS automatically detaches the tracing module and restores the method to the initial state (state prior to enhancement).

  5. Parameter printing: Currently, EDAS only supports printing of basic Java types (string, char, int, float, double, short, and boolean).

  6. If the selected string is too long, EDAS truncates the string to output the first 100 characters.

  7. If the JVM instance restarts during the tracing process, you must stop tracing and then restart it.

  8. Currently, a maximum of 10,000 trace logs can be output. To output more logs, restart the tracing function.

  9. The current version does not support Docker-based applications.

Environment check

Because the method tracing function adopts the JVM bytecode enhancement technique, to ensure normal running of applications, this function is disabled when the environment check fails.

Before the method tracing function starts, EDAS automatically checks that:

  1. Ali-Tomcat is in Running state.
  2. CPU usage is lower than 60%.
  3. Available system memory is more than 100 MB.
  4. The available space of JVM PermGen or Metaspace is more than 20 MB.

If the environment check fails, we recommend that you clear the alarms and then click Retry.

Usage instructions

  1. Log on to the EDAS console.

  2. Click Applications in the left-side navigation pane and click the name of the application to be checked in the application list.

  3. Click Application Diagnosis in the left-side navigation pane of the Application Details page.

  4. Click the Method Tracing tab on the application diagnosis page.

    Note:

    If the Method Tracing tab does not appear, follow these steps:

    1. Check that you are using Google Chrome as the web browser, and refresh the page. (We performed tests in Google Chrome only.)

    2. If you log on with a sub-account, check that the sub-account has required permissions.

      To check permissions, choose Applications > Application Diagnosis > Method Tracing and Tool Authorization.

  5. Before the permission check starts, EDAS performs an environment check on the ECS instance where the application is located. When the environment check dialog box appears, select the checkbox to confirm the precondition and click Confirm to start the environment check.

    The method tracing page appears after the environment check is successful.

  6. Set tracing parameters.

    Note: Class Name and Method Name are required. Set the two parameters to the class and method you want to trace.

    The configuration items are described as follows:

    • Class Name: Required. Enter a full path name starting with the package path, for example, com.test.alibaba.demo.HelloWorldServlet. EDAS does not support tracing of classes whose names start with the following package paths:

      • java.*
      • javax.*
      • com.google.*
      • com.alibaba.*
      • com.aliyun.*
      • com.taobao.*
      • org.apache.*
      • org.dom4j.*
      • org.springframework.*
      • redis.clients.*

      After a complete package path is entered, EDAS checks whether the class exists on the selected ECS instance.

      • If the entered class exists, it is displayed in the drop-down list. Select the class to continue.
      • If the entered class does not exist, the message “Class does not exist” is displayed in the drop-down list.
    • Method Name: Required. After a class is selected, the system automatically searches for all methods under the class and displays the method list below the textbox.

      The icon on the left of each method indicates the modifier of the method.

      • public: A green lock
      • protected: A yellow key
      • private: A red lock
      • package: A blue block
      • abstract: No icon

      Select the method to be traced from the drop-down list and continue.

      • Exception Tracing Only: The execution of a method either returns a response normally or ends execution due to an exception. If you select “Exception Tracing Only”, the tracing results are printed and output only when the method is ended due to an exception.

      • Print Returned Values: If you select this option, the returned values of the method are printed on the result page. null is output if the return type of the method is void.

    After a method is selected, the Start Tracing button is available in blue.

  7. Click Start Tracing to trace the method. Whenever the method is called, the call information is displayed in the result area.

    Note: After method tracing starts, EDAS periodically checks whether the tracing is in active state. If method tracing is in inactive state for 10 minutes, EDAS automatically stops the tracing and restores the method to the initial state.

  8. Check the method call information.

    After method tracing starts, EDAS displays the generated call logs in the EDAS console.

    On the left of the display area, each record represents the log that is generated each time the method is called.

    • 44-62/150 at the bottom of the table indicates that the browser returns 150 records in total and currently lists the trace records in rows 44 to 62.

    • The prompt “Press key H to show help information” is displayed at the bottom of the table. Press “H” on the keyboard to display the usage instructions on shortcut keys.

      • H: Displays the help document.
      • Ctrl+G: Displays the latest data in real time. As the call times increase, it is impossible to render and display all records. Similar to the tail function, Ctrl+G is used to display the latest data once retrieved.
      • G: Jumps to a specific record. Search for the trace record in a specific row and select it to display details.
      • Ctrl+C or ESC: Ends the command that is being executed.
      • Ctrl+H: Goes to the next page to display the next 10 trace records.
      • Ctrl+I: Returns to the previous page to display the preceding 10 trace records.
      • J or : Selects the next trace record.
      • K or : Selects the previous trace record.
      • Enter or Double-click: Zooms in or restores the selected trace record.

    The right side of the display area displays the details or basic information of the selected record. You can double-click or press Enter in the details section to zoom in, or press ESC to restore to initial display.

    • Tracing details: Shows the time consumption and execution sequence for each call.The time in blueis the total time consumed by calling the method.The time in redindicates that the time of the specific call is more than 30% of the total time consumed.
    • Output details: Shows the exceptions, return values, and input parameters (which are selected using the More option) during execution.
    • Method stack details: Shows the stack information before the traced method is called.
  9. Stop tracing.

    After method tracing starts, the Start Tracing button changes to Stop Tracing. After you click Stop Tracing, EDAS restores the traced method to the initial state (state prior to enhancement) and records tracing information in the instance dimension. Next time you go to the method tracing page, the last tracing information is displayed.

    If you modify tracing items (for example, method name) after tracing stops and then click Start Tracing, the modified information is submitted and tracing starts based on the latest submitted information.

Thank you! We've received your feedback.