Identify business exceptions by analyzing traces and logs
Last Updated: Jan 12, 2021
The difficulty and low efficiency in identifying business exceptions have always been
performance bottlenecks of the application monitoring feature of Application Real-Time
Monitoring Service (ARMS). However, you can use the application monitoring feature
of ARMS together with traces and logs to efficiently and accurately identify business
exceptions. This improves the efficiency of development and diagnostics in a microservices
framework.
Prerequisites
Log Service is activated. Log on to the Log Service console and activate Log Service by following the on-screen instructions.
A project is created. For more information, see Create a project.
Before you identify business exceptions by analyzing traces and logs, you must understand
the following terms: metric, tracing, and logging.
Metric: The key metrics of an application include Application Service Request, Application
Service Average Response Time, and Application Dependent Service Request.
Tracing: All activities of an application, such as API calls and responses, are recorded
in traces.
Logging: All activities of an application, such as API calls and responses, are recorded
in business logs.
When a business exception occurs, the statistical chart for an application metric
shows obvious fluctuations. You can roughly analyze the business exception based on
the chart. You can also analyze the complete traces and business logs to accurately
identify the business exception.
In the left-side navigation pane, choose Application Monitoring > Applications. In the top navigation bar, select a region. On the Applications page, click the name of the application.
In the left-side navigation pane, click Application Settings. On the page that appears, click the Custom Configuration tab.
On the Custom Configuration tab, turn on Link Business Logs with TraceId in the Business Log Linking Settings section. Then, specify the project and Logstore that store the business logs to be
associated with trace IDs.
On the Custom Configuration tab, click Save in the lower-left corner.
Troubleshoot business exceptions from the perspective of application metrics
In the left-side navigation pane, choose Application Monitoring > Applications. In the top navigation bar, select a region. On the Applications page, click the name of the application.
In the left-side navigation pane, click Application Overview. On the page that appears, click the Overview tab in the upper part and select or set a time range to query in the upper-right
corner.
The Overview tab displays key metrics of the application, including Application Service Request, Application Service Average Response Time, and Application Dependent Service Request.
On the Overview tab, drag-select a time range on the chart for an application metric.
In this example, the Application Service Average Response Time metric is used.
View the traces that were generated in the time range selected in Step 4.
Click View CallChain selected time.
In the panel that appears, find the trace record whose status is and click the trace ID in the TraceId column.
You can also click View Logs in the Actions column for the trace record to view the business logs that were generated at the
specified time point. Then, you can analyze the cause of the business exception.
Click the Traces tab. In the Method Stack column, click the icon.
On the trace details page, find the error message. You can move the pointer over the
error message to view the exception cause.
View the business logs that were generated in the time range selected in Step 4.
Click View Log selected time.
On the log analysis page, find the error message of the business exception and identify
the cause of the business exception.
Troubleshoot business exceptions from the perspective of API calls
In the left-side navigation pane, choose Application Monitoring > Applications. In the top navigation bar, select a region. On the Applications page, click the name of the application.
In the left-side navigation pane, click Interface Invocation.
On the page that appears, click the API operation that you want in the API operation
list and click the Interface Snapshot tab on the right.
On the Interface Snapshot tab, find the API call record whose status is .
View the trace for the API call.
Click the trace ID in the TraceId column for the API call record.
Click the Traces tab. In the Method Stack column, click the icon.
On the trace details page, find the error message. You can move the pointer over the
error message to view the exception cause.
View the logs for the API call.
Click View Logs in the Actions column for the API call record.
On the log analysis page, find the error message of the business exception and identify
the cause of the business exception.