This topic shows you 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 you create a service

  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 Services and Functions. Click Create Service in the upper-right corner of the Services pane.
    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 in 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 Services and Functions. In the Services pane, click the service that you require.
  4. On the Services and Functions page, click the service that you require. Then, click the Service Configurations tab. On the Service Configurations tab, click Modify Configuration.
    Modify service configurations
  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 in 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. On the Functions tab, click the name of the function that you require.
  4. On the details page of the function, click the Traces tab to view the trace information of the function. For more information, see Analyze traces.
  5. On the Traces tab, click a specific trace to view the detailed information.
    cold-start

    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.