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

Background information

Overview

Enable Tracing Analysis when you create a service

  1. Log on to the Function Compute console.
  2. In the left-side navigation pane, click Services and Functions.
  3. In the top navigation bar, select a region.
  4. On the Services page, click Create Service.
    create_service_new
  5. In the Create Service panel, set the Name parameter as required, set the Tracing Analysis parameter to Enable, and then click OK.
    Note After you enable Tracing Analysis, Tracing Analysis is enabled for all functions in the service.
    lianluzhuizongpeizhichuangjianfuwu

Enable Tracing Analysis for a created service

  1. Log on to the Function Compute console.
  2. In the left-side navigation pane, click Services and Functions.
  3. In the top navigation bar, select a region.
  4. On the Services page, find the desired service. Click Configure in the Actions column.
  5. In the Tracing Analysis Settings section of the Modify Service page, set the Tracing Analysis parameter to Enable, and click Save.
    lianzluzhuizongpeizhiqiyong

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.

  1. Log on to the Function Compute console.
  2. In the left-side navigation pane, click Services and Functions.
  3. In the top navigation bar, select the region where your Kubernetes cluster is deployed.
  4. On the Services page, click the name of the specified service.
  5. On the Functions page, click the name of the specified function.
  6. On the Function Details page, click the Tracing Analysis tab to view the trace information of the function. For more information, see Analyze traces.
    Tracing Analysis tab
  7. On the Tracing Analysis tab, click a specific trace on the Traces tab 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.