slanatech / swagger-stats

API Observability. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices.
https://swaggerstats.io/
MIT License
906 stars 139 forks source link

URL Normalization and 404 count consolidation by config option without requiring swagger apiSpec #266

Open zeatful opened 1 year ago

zeatful commented 1 year ago

Issue: By default, all 404 URLs and handled URLs in general generate their own metrics. We also have internal built-in health checks that display in these metrics which we wish to filter or hide. This can quickly bloat the metrics if many 404s hit the application. In my own organization we have instituted a metrics limit to protect from this behavior and limit the impact on our systems.

Current Solution: I have observed that specifying swaggerOnly: true and swagger:apiSpec in the configuration forces URL Normalization and avoids capturing unhandled routes, including 404s and health checks. This means that 404s no longer generate metrics, but we lose visibility on 404s as well and requires a swagger.json be supplied.

Proposed Additional solution:

I don't mind taking a whack at this myself and submitting a PR, but obviously I'm not sure if there is consensus or issues I'm not considering.

sv2 commented 1 year ago

Sounds reasonable ... would appreciate PR !