how to find root spans with lots of children (N+1 queries) in datadog apm traces?

how to find root spans with lots of children (N+1 queries) in datadog apm traces?


0

I’ve noticed a few N+1 queries in our graphql app. The fix in each case is to add a dataloader to the first repeated query, but finding them is hard.

I would like to find all requests that have this problem.

The SQL query is in the resource column in apm.

I would like to be able to do something like (pseudocode):

select count(*), root_span_id, resource
from spans
group by root_span_id, resource
order by count desc

and then dig into any requests that are making a lot of the same sql requests.

If it is not possible to group on two columns then grouping by root_span_id would be enough to get me started.

Unfortunately, @_trace_root is just a boolean (1 or empty) telling me whether something is a root span or not.

Is there a column that I can group by to group by root span, or another way to hunt for n+1 queries in datadog?

I feel like sentry has done this n+1 query hunting for me automatically on previous projects, but I never dug into how it’s done, and I can’t seem replicate it on datadog. Any ideas?


Load 2 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *