Code Diagnosis

Updated at:

The Code Diagnosis feature, a collaboration between Log Service and Alibaba Cloud DevOps Codeup, helps you pinpoint and jump to the relevant code with a single click to troubleshoot and fix issues faster.

Prerequisites

  • Log Service
    • You have collected logs in a Logstore. For more information, see Data collection.
    • You have configured an index. For more information, see Create an index.
  • Alibaba Cloud DevOps Codeup

    You have created a code repository and committed your code. For more information, see Quick start guide.

Background

Alibaba Cloud DevOps Codeup is an enterprise-grade code management platform from Alibaba Cloud. It provides features such as code hosting, code reviews, code scanning, and quality checks to secure your code assets and enable secure, stable, and efficient development. Log Service and Alibaba Cloud DevOps Codeup have collaborated to introduce the Code Diagnosis feature. You can upload your code to Alibaba Cloud DevOps Codeup and your logs to Log Service. The Code Diagnosis feature uses code location information from your logs to quickly pinpoint and jump to the exact line of code to help you troubleshoot and fix issues.

Procedure

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. On the Log Storage > Logstores tab, click the logstore you want.

    image

  4. Optional: Enter a query statement in the search box, select a time range, and then click Query/Analyze.

    You can also use Data Explorer to build query and analysis statements. For more information, see Use Data Explorer to build query and analysis statements. For more information about the query syntax, see Query syntax and functions.

  5. On the Raw Logs tab, click the target string, and then click View Source Code.
  6. In the Advanced Event Settings dialog box, configure the interaction event.
    1. In the Field List area, select the target field, and then click Add Event.
      You can configure separate interaction events for multiple fields.
    2. In the Event Settings area, add an interaction event.
      Note If the RAM user you are using does not have permission to access the code repository, select the Automatically grant Visitor role to RAM users without repository access checkbox. Otherwise, the user cannot view the code.
      • After you select this option, the system automatically adds the RAM user to the enterprise and grants them the Visitor role for the current code repository. A Visitor can only view the code repository and cannot write code.
      • Granting permissions to a RAM user in this dialog box is a one-time operation. To modify the permissions, go to the target code repository. For more information, see Permissions.
      Parameter Description
      Configuration name Specify a name for the event.
      Event action Set the event action. In this example, select View Source Code.
      Enterprise Select the enterprise that you created.

      Alibaba Cloud DevOps Codeup is an enterprise-level code management platform that provides enterprise-level data isolation. For more information, see Manage an enterprise.

      Code path Select the code repository that you created.
      Alibaba Cloud DevOps Codeup provides a one-click import feature for code repositories. If your code is stored in a third-party code repository such as GitHub, you can import it into Alibaba Cloud DevOps Codeup first and then view the source code. The following parameters are required:
      • Source code repository URL: The URL of the third-party code repository.
      • Third-party account: The account for the third-party code repository.
      • Access token: The access token for the third-party account. For instructions on how to obtain an access token, see Add an access token.

        The access token you provide is used only for importing the code repository. Alibaba Cloud does not store or use it for any other purpose.

    3. Click Confirm.
    After the configuration is complete, click a value of the configured field, and then click the interaction event that you added. This action redirects you to the target code repository. When you click a field value, a context menu appears. The menu is divided into the Preset and Advanced sections. The Preset section includes options such as Add to Query, Exclude from Query, New Query, and Go to Data Transformation. Your Custom Event appears in the Advanced section.