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:
parent
80b0dcd5ba
commit
9af50a9e34
1 changed files with 6 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue