Extract business parameters from Go applications

Updated at:

Application Real-Time Monitoring Service (ARMS) extracts business parameters from Go application call chains in a non-intrusive manner and writes specified request and response parameters to Span Attributes. You can configure extraction rules in the ARMS console to capture parameters on demand and set up custom error filtering based on extracted values.

Prerequisites

  • The Go agent has been installed for your Go application.

  • The Go agent version is 2.10.2 or later.

Supported scope

Business parameter extraction rules have requirements on frameworks and usage. The following table lists the parameter extraction types and sources supported by the Go agent:

Extraction type

Extraction source

Supported frameworks

Notes

HTTP Server Request

Header, Query Parameter

HTTP protocol-related frameworks

-

HTTP Server Response

Header, Body

HTTP protocol-related frameworks

The body must be in JSON format.

HTTP Client Request

Header, Body

HTTP protocol-related frameworks

The body must be in JSON format. If the body is long, adjust the extraction value length limit.

HTTP Client Response

Header

HTTP protocol-related frameworks

-

If the parameter source you need is not within the supported scope listed above, you can add custom instrumentation by importing the OpenTelemetry SDK to write business parameters as Attributes into Spans.

Access the feature

  1. Log on to the ARMS console. In the left-side navigation pane, choose Application Monitoring > Applications.

  2. In the top menu bar, select the target region, and then click the name of the target Go application.

  3. In the left-side navigation pane, click Application Settings, and then click the Custom Parameters tab.

In the Parameter Extraction Rule section, you can create, view, and modify business parameter extraction rules for the current application. The agent dynamically detects rule changes and extracts business parameters according to all enabled rules. In the Custom Error Settings section, you can configure custom error rules to filter the extracted business parameter values.

Create an extraction rule

In the Parameter Extraction Rule section, follow these steps to create an extraction rule:

Important

The first time you create an extraction rule, you must restart the application for the feature to take effect. Subsequent rules do not require a restart and are expected to take effect within 1 to 2 minutes.

  1. Click Create Rule.

  2. Enter the Rule Name and Attribute Name.

  3. Select the Parameter Extraction Type and configure the Active Interface to specify the scope of interfaces that the rule applies to.

  4. In the Parameter Extraction Rule section, add parameter sources and configure parameter processing steps. You can configure multiple parameter sources and processing steps. If multiple sources can extract the parameter, the source with a higher position in the list has higher priority.

  5. Set the Enable toggle, and then click Save.

After a rule is created and enabled, it is delivered to the client agent in real time. Extracted business parameters are recorded in the Attributes of the corresponding call chain Span. You can filter and query them on the Trace Analysis page. Attribute names have the biz. prefix by default and must be unique.

Rule configuration

Parameter

Description

Rule Name

A human-readable name for the rule.

Attribute Name

The Span Attribute name for the extracted value. It starts with biz. by default, followed by multiple words. Each word can contain only uppercase and lowercase letters, digits, hyphens (-), and underscores (_). Words must be separated by a period (.). A maximum of 10 words are allowed.

Parameter Extraction Type

The type of parameter to extract.

Active Interface

The scope of interfaces that the rule applies to. The agent only extracts parameters from interfaces that match the rule.

Parameter Extraction Rules

Defines the actual source where the parameter resides and how it is processed after extraction. You can configure multiple parameter sources and extraction steps. If multiple sources can extract the parameter, the extraction step with a higher position in the list has higher priority.

Parameter Source

The actual source where the parameter resides.

Parameter Processing Steps

Sequential parameter processing steps used to parse the parameter source and extract the final parameter value. You can add multiple processing steps, where the output of the preceding step becomes the input of the next step. If no processing step is added, the extracted parameter value is the JSON text of the source object.

Enable

Whether to enable the rule.

Parameter processing methods

The following table lists the parameter processing methods supported by the Go agent:

Processing method

Input

Output

Description

JsonPath

JSON string

String

Supports dot notation JsonPath expressions. Example: $.data.code.

Regex

String

String

Supports regular expressions with named groups. The substring to extract corresponds to the group named res. Example: .*from:(?<res>[a-z]+).*.

Verify the rule

After a parameter extraction rule is configured, it is expected to take effect within 1 to 2 minutes (except for the first rule created, which requires an application restart). Verify that the rule is working on the Trace Analysis page.

  1. In the left-side navigation pane, click Trace Analysis.

  2. Add the Attribute name with the biz. prefix as a query condition to filter relevant Spans. For example, enter attributes.biz.order_id where order_id is the Attribute Name you configured.

  3. Click any Trace and view the custom Attributes under the corresponding Span.

If custom Attributes have been written to the Span Attributes of the corresponding interface, the extraction rule is effective.

Manage rules

  • Enable or disable a rule: Toggle the Enable switch on the right side of the target rule.

  • Edit or delete: Click Edit or Delete on the right side of the target rule to modify or delete it.

  • Batch delete: Select the extraction rules to delete, and then click Batch Delete.

  • Batch copy: Select the extraction rules to copy, click Batch Copy to Other Applications, and then select whether to copy to all other applications or specific applications in the dialog box.

    • Batch copying to other applications is expected to take effect within 1 to 2 minutes.

    • This feature only copies parameter extraction rules. Associated custom errors are not copied to the target application.

    • Parameter extraction rules require unique Attribute names. If the target application already has the same Attribute name, the rule is not copied to the target application.

FAQs

What causes parameter extraction to fail?

  • The extraction type or source is not within the supported scope. Refer to the Supported scope section to verify whether the current framework and source are supported.

  • The syntax of the parameter processing step is incorrect, or the input type does not match the requirements of the processing method.

  • The Go agent version is too low and does not support the business parameter extraction feature.

  • The matching rule for the active interface is incorrectly configured, causing the target interface to not be matched.

How to extract business parameters from sources not currently supported by the Go agent?

You can add custom instrumentation by importing the OpenTelemetry SDK for your Go application to write business parameters as Attributes into Spans.