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
2
u/Agitated-Student4716 May 18 '26
Great question – and honestly one of the core design decisions we wrestled with.
The short answer: Claude never executes anything. It only proposes.
Here's how validation works in practice:
The deterministic layer runs first. Policy.py evaluates P95 latency, error rate, and anomaly score against adaptive thresholds. This decides whether an incident exists — no AI involved at this stage.
Claude only runs after the deterministic engine has already confirmed something is wrong. At that point Claude gets the health metrics, the trend direction, and the service context and produces a plain English diagnosis with a confidence score.
If confidence is below 0.6, the system suppresses the AI recommendation entirely and falls back to rule-based classification. So Claude's output is already filtered before it reaches the operator.
The operator then sees both the raw metrics and Claude's diagnosis before deciding. The WhatsApp message shows what the numbers say, what Claude thinks, and what action is proposed. The operator can simply ignore the recommendation and investigate manually — the approval tap is explicit, not automatic.
And if Claude is completely wrong — the worst outcome is the operator sees a confusing diagnosis and decides not to tap 'approve'. Nothing executes. The system fails safely. I built it this way specifically because I don't trust AI diagnoses enough to automate execution. The human stays in the loop precisely because Claude can be wrong.