Many Java frameworks can be used to automatically instrument applications based on the bytecode injection technology of Java. This way, you can know the spans between which a slow request occurs. However, this is not enough to identify issues at the code level. To find specific methods that cause slow requests, you can use the slow request analysis feature of SkyWalking together with Managed Service for OpenTelemetry.
Prerequisites
SkyWalking is connected to Managed Service for OpenTelemetry. For more information, see Use SkyWalking to report Java application data.
Background information
The following figure shows how SkyWalking collects slow request data.
Only SkyWalking 7.0 or later supports the slow-request analysis feature.
Create a slow-request collection task
Log on to the Managed Service for OpenTelemetry console. In the left-side navigation pane, click Applications.
On the Applications page, select a region in the top navigation bar and click the name of the application.
In the left-side navigation pane, click Slow Request Analysis. On the page that appears, click Create a task.
In the Create a task dialog box, configure parameters and click OK. The following table describes the parameters.
Parameter
Description
Required
Example
Span name
The name of the span that you want to monitor.
Yes
/api
Monitoring duration
The duration of the monitoring.
No
5 min
Span time-consuming threshold
The threshold of the span duration. The span is analyzed only when its duration exceeds this threshold. Unit: millisecond.
No
30 ms
Monitoring interval
The interval at which monitoring data is collected.
No
20 ms
Maximum number of samples
The maximum number of data samples that are collected for the span. Valid values: 1 to 9.
No
5
After the task is created, it is displayed in the Task list section.
Find the methods that cause slow requests
After the specified monitoring duration that starts from the specified monitoring time ends, the spans whose duration exceeds the threshold are displayed in the Sampled Traces section. Perform the following steps to find the methods that cause slow requests based on the thread stack details on the right of the page:
On the Slow Request Analysis page, click the task that you created in the Task list section.
The spans whose duration exceeds the threshold are displayed in the Sampled Traces section.
In the Sampled Traces section, click the span that you want to check and view the content in the Thread Stack section on the right of the page.
Methods that involve spans whose duration exceeds the specified threshold are displayed in red. You can optimize these methods.
How do I do if no thread stack is sampled after the monitoring duration ends?
If no thread stack is sampled after the monitoring duration ends, perform the following steps to troubleshoot this issue:
In the Task list section of the Slow Request Analysis page, click View task details on the right of the task that you created.
View the task details in the Task details dialog box.