Performance Analysis for Trpc api
Hey 👋 , I have been facing performance bottlnecks in some of my APIs, I used to code in django before, I used gprof2dot to profile apis, Is there a similar tool for trpc?
12 Replies
what is exactly slow?
the api endpoints take couple of seconds to load, and there are so many function calls happening in the routes, need a tool which show flow map with timings of execution of each functions etc
add tracing
Axiom
Stop sampling, observe every event – Axiom
100% of your data for every possible need: o11y, security, analytics, and new insights.
most likely it would be two separate instances that are called together
@cje does axiom play nice with trpc?
thank you will check this out!
you can get something like this
![No description](https://cdn.answeroverflow.com/1261313822283792444/Screenshot_2024-05-30_at_14.png)
What do you mean by "play nice with tRPC"?
If you don't want to setup OTel tracing, we have an example for the
next-axiom
library with tRPC https://github.com/axiomhq/next-axiom/tree/main/examples/trpc-app-router
you could modify the middleware to console.time
or similar before/after the procedure to get info on how long it takes to run. https://github.com/axiomhq/next-axiom/blob/main/examples/trpc-app-router/src/server/api/axiom-trpc.ts
If you do want to setup OTel tracing, that works as well (see attached screenshot from my side project), although OTel + Next.js, especially app dir, is kind of a mess.![No description](https://cdn.answeroverflow.com/1261314212370579557/CleanShot_2024-07-12_at_15.31.142x.png)
bad wording on my part
thanks cje, this was helpful !
never used Otel before, will integrate it to my app
I use page router and not the new one, soI think Otel+nextjs shouldnt be a mess
just don't use the vercel integration
I have it deployed it on Digital ocean