This topic describes how to configure Tracing Analysis, use custom Tracing Analysis endpoints, and view the trace information of a function in the Function Compute console.

Background information

Overview

Configure Tracing Analysis when a service is created

  1. Log on to the Function Compute console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Service/Function. On the Service/Function page, click Create Service in the upper-right corner.
    creat_service
  4. On the Create Service page, enter a service name, select Enable Tracing Analysis, and then click Submit.
    Note When Enable Tracing Analysis is selected, Tracing Analysis is enabled for all functions of the service.
    enter_name

Configure Tracing Analysis after a service is created

To enable Tracing Analysis for a created service, perform the following steps:

  1. Log on to the Function Compute console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Service/Function. In the Services pane, click the required service.
  4. On the Service/Function page, click Service Configurations. On the Service Configurations tab, click Modify Configurations.
    Modify configuration
  5. In the Tracing Analysis section on the Configure Service page, turn on Enable Tracing Analysis and click Submit.
    Enable Tracing Analysis

View the trace information of a function

After Tracing Analysis is enabled for your service, Function Compute automatically records the trace information of all functions of the service. To view the trace information of a function, perform the following steps:

  1. Log on to the Function Compute console.
  2. In the top navigation bar, select a region.
  3. Find the required function in the required service and click the name of the function.
    requiredfunction
  4. On the details page of the function, click Trace Query to view the trace information of the function. For more information, see Analyze traces.
  5. On the Trace tab of the Trace Query page, click a specific trace to view the detailed information.

    The trace contains the following spans:

    Note If a request does not encounter a cold start, the trace does not contain the ColdStart and Initializer spans.
    • TracingService/TracingFunction: the total stay time of the current request in Function Compute. By default, this span is named in the format of serviceName/functionName.
    • ColdStart: the cold start time of the system for the function. A cold start does not occur every time you invoke a function, and occurs only when you reapply for the execution environment.
      • PrepareCode: the time that is taken to download code or a custom image for the function. If the time indicated by the PrepareCode span is too long, simplify the code package to reduce the time that is taken to prepare code.
      • RuntimeInitialization: the time that is taken to start the execution environment, including the time that is taken to start an instance and the time that is taken to perform health check on the instance. In a custom runtime and a custom image, if the time indicated by the RuntimeInitialization span is too long, check the startup behavior of the corresponding HTTP server and image.
    • Initializer: the time that is taken to execute the initialization function. The initialization function is executed only when the container is cold started.
    • Invocation: the time that is taken to execute the function. You can check the context of Invocation in the function to obtain the execution time.