stephenhillier / starlette_exporter

Prometheus exporter for Starlette and FastAPI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is the difference between handle_openmetrics and handle_metrics?

chenxin6 opened this issue · comments

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.

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!