r/FastAPI • u/silksong_when • Apr 29 '26
Tutorial A Practical Guide to OpenTelemetry and FastAPI
https://signoz.io/blog/opentelemetry-fastapi/Hey folks, I recently revamped our article on Implementing OpenTelemetry in FastAPI Projects in a practical manner, which was originally written in 2024 and needed a fresh coat of paint.
The article covers auto-instrumentation, manual spans, visualizing metrics and how observability lets you understand how your web apps behave.
I've also included some advanced tips, such as, selective error tracking, and wrapping dependency functions to capture any operations within the `yield` scope.
If you are on the fence about observability, or have integrated it but don't really how it works, I believe this guide can help you out.
I personally would have benefitted from this writeup in my previous day job, where I worked with FastAPI microservices and learnt how OpenTelemetry worked the hard way.
Any feedback would be much appreciated, did I miss anything, is there scope for improvement? Please let me know. I'm also curious to understand what problems you face with monitoring your FastAPI web apps.
View all comments
Show parent comment
3
u/silksong_when May 02 '26
Hey, you're on the right path!
Auto instrumentation does add substantial overhead, the measurements vary and you'll have to benchmark it on your machine with real load, but a ballpark figure can be ~10%.
I would recommend that you selectively install auto instrumentation libraries, that should cut down on the overhead a lot. For example, the db layer can emit 10s of query spans per API call, which can be unneeded based on your use case.