DEV Community

Ayo
Ayo

Posted on

Adding Python support to Pingoni: Flask, FastAPI, and one embarrassing backend bug

Pingoni started as a Node-only tool. Drop-in monitoring for Express: one npm install, and you see every request, error and response time on a dashboard. I built it because my final project broke overnight before a presentation and I found out the morning of. Never wanted that to happen again.

But Node-only was limiting who could use it. So the last two weeks I built Python support. Flask and FastAPI, same idea:

from pingoni import init_flask

init_flask(app, api_key="your_key")
Enter fullscreen mode Exit fullscreen mode

That's the whole setup. Requests, errors, stack traces and response times start showing on your dashboard right away. Alerts are on by default, so if your error rate spikes you get an email. There's also LLM cost tracking if your app calls OpenAI.

The bug I found while testing

This part is more interesting than the feature honestly.

While testing the Python SDK, only 1 of my 3 test requests was reaching the dashboard. The error request arrived fine. The successful ones vanished. No errors anywhere, they just disappeared.

I added debug prints to the SDK and saw this:

[PINGONI DEBUG] FAILED / -> HTTPError: HTTP Error 400: Bad Request | body: {"error":"Missing required fields"}

Missing required fields? The payload had every field. Took me a while staring at the backend validation to see it:

if (!method || !endpoint || !status_code || !response_time) {
  return res.status(400).json({ error: "Missing required fields" });
}
Enter fullscreen mode Exit fullscreen mode

My test endpoints were responding in 0ms. And in JavaScript, !0 is true. So response_time: 0 was being treated as "missing" and rejected.

The fix is one line:

if (!method || !endpoint || status_code == null || response_time == null) {
Enter fullscreen mode Exit fullscreen mode

Here's the part that stung: this bug was live in production the whole time. Any request faster than 1ms was silently dropped, for every user, including Node users. My own test requests during development were usually slow enough to pass, so I never saw it. It took building a second SDK to find a bug in the first one.

Lesson: if you validate numbers with truthy checks, zero will betray you eventually.

What's next

Python SDK is live. If you run a Flask, FastAPI or Express API and want to know when it breaks before your users tell you, it's free for 10k requests a month: pingoni.com

If you try it and something sucks, tell me. I fix things fast, it's just me building this.

Top comments (0)