docs/en/setup/backend/backend-trace-profiling.md
Trace Profiling is bound within the auto-instrument agent and corresponds to In-Process Profiling.
It is delivered to the agent in the form of a task, allowing for dynamic enabling or disabling.
Trace Profiling tasks can be created when an endpoint within a service experiences high latency.
When the agent receives the task, it periodically samples the thread stack related to the endpoint when requested.
Once the sampling is complete, the thread stack within the endpoint can be analyzed to determine the specific line of business code causing the performance issue.
Lean more about the trace profiling, please read this blog.
OAP and the agent use a brand-new protocol to exchange Trace Profiling data, so it is necessary to start OAP with the following configuration:
receiver-profile:
selector: ${SW_RECEIVER_PROFILE:default}
default:
To use the Trace Profiling feature, please follow these steps:
Creating a Trace Profiling task is used to notify all agent nodes that execute the service entity which endpoint needs to perform the Trace Profiling feature. This Endpoint is typically an HTTP request or an RPC request address.
When creating a task, the following configuration fields are required:
When the Agent receives a Trace Profiling task from OAP, it automatically generates a log to notify that the task has been acknowledged. The log contains the following field information:
At this point, Tracing requests matching the specified Endpoint and other conditions would undergo Profiling.
Notice, whether profiling is thread sensitive, it relies on the agent side implementation. The Java Agent already supports cross-thread requests, so when a request involves cross-thread operations, it would also be periodically sampled for thread stack.
Once the Tracing request is completed, we can query the Tracing data associated with this Trace Profiling task, which includes the following information:
Once we know which segments can be analyzed for profiling, we can then determine the time ranges available for thread stack analysis based on the "profiled" field in the span. Next, we can provide the following query content to analyze the data:
By combining the segmentId with the time range, we can confirm the data for a specific thread during a specific time period. This allows us to merge the thread stack data from the specified thread and time range and analyze which lines of code take longer to execute. The following fields help you understand the program execution:
If you want to learn more about the thread stack merging mechanism, please read this documentation.
If you find that the results of profiling data are not correct, you can report an issue through this documentation.