Prometheus metrics for request latency

10769
0

During an incident, the first question is usually ‘is it getting worse?’, and log lines don’t answer that well. Prometheus-style metrics make it easy to track rates and percentiles over time. I instrument request duration as a histogram and label by method, route, and status class. The trick is controlling label cardinality—don’t label by user id or raw URL, or your metrics backend will hate you. I also expose a /metrics endpoint that’s protected (or internal-only) so I’m not handing out operational data publicly. With a small amount of code, you get dashboards and alerts that make on-call much less stressful and performance work much more measurable.