How to aggregate trace samples by specific span?

Hi, everyone.
I have this scenario,I already have 1000 request trace samples, and each sample is made up of several steps, like this:
request sample:
step 1: do some redis;
step 2: call third party service;
step 3: do some mysql;
finally: response.

I wanna aggregate the 1000 samples, count the average cost time or percentile of "step 1/2/3", and how it takes up the whole time.
Where do I go to find the docs?anybody can help?