stephenhillier / starlette_exporter

Prometheus exporter for Starlette and FastAPI
Apache License 2.0
315 stars 35 forks source link

What is the difference between handle_openmetrics and handle_metrics? #95

Open chenxin6 opened 8 months ago

chenxin6 commented 8 months ago

As the README.md says, we must use handle_openmetrics instead of handle_metrics for exemplars to appear in metrics output. Does it mean that handle_openmetrics is better than handle_metrics? And we should always use handle_openmetrics.

stephenhillier commented 8 months ago

I'm not aware of any advantages or disadvantages to using handle_openmetrics other than the addition of exemplars, but I could be wrong about that. They should both be compatible with Prometheus scraping.

Edit: handle_metrics and handle_openmetrics are just simple wrappers around the Prometheus and OpenMetrics exposition formats that are both built into the official Prometheus client, so the answer to your question would come down to differences in those two formats. If I had to choose between them it would be OpenMetrics simply due to to the added exemplar support, and (to my knowledge, for my use cases) no downside. Would appreciate hearing other viewpoints!