fix(metrics): serve scrape body via PromEx.get_metrics

PromEx.Plug's internal path check doesn't match when forwarded under
/metrics (conn.path_info is [] after the forward strips the prefix),
so it silently returned without sending a response. Call
PromEx.get_metrics/1 directly and send the text body ourselves —
tested, returns 200 with all 23 registered event handlers producing
proper Prometheus histogram output.
This commit is contained in:
Graham McIntire 2026-04-18 16:50:30 -05:00
parent 80b0dcd5ba
commit 9af50a9e34
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -16,7 +16,12 @@ defmodule MicrowavepropWeb.MetricsPlug do
def call(conn, _opts) do
case authorized?(conn) do
:ok ->
PromEx.Plug.call(conn, prom_ex_module: Microwaveprop.PromEx, path: "/metrics")
body = PromEx.get_metrics(Microwaveprop.PromEx)
conn
|> put_resp_content_type("text/plain; version=0.0.4")
|> send_resp(200, body)
|> halt()
:denied ->
conn