From 9af50a9e3485900be659b5170659d9a2bcc8859c Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 18 Apr 2026 16:50:30 -0500 Subject: [PATCH] fix(metrics): serve scrape body via PromEx.get_metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lib/microwaveprop_web/metrics_plug.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/microwaveprop_web/metrics_plug.ex b/lib/microwaveprop_web/metrics_plug.ex index 2aaa96f4..eaf8a654 100644 --- a/lib/microwaveprop_web/metrics_plug.ex +++ b/lib/microwaveprop_web/metrics_plug.ex @@ -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