diff --git a/CHANGELOG.md b/CHANGELOG.md index 86f69c6..245f98b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.11.0] - 2024-10-24 + +### Fixed + +- Phoenix plugin was not properly handling multiple endpoints [#254](https://github.com/akoutmos/prom_ex/pull/254). + ## [1.10.0] - 2024-08-10 ### Added diff --git a/lib/prom_ex/plugins/phoenix.ex b/lib/prom_ex/plugins/phoenix.ex index a9a21a7..8beb068 100644 --- a/lib/prom_ex/plugins/phoenix.ex +++ b/lib/prom_ex/plugins/phoenix.ex @@ -190,7 +190,6 @@ if Code.ensure_loaded?(Phoenix) do defp endpoint_info(metric_prefix, opts) do phoenix_endpoints = normalize_endpoint(opts) - keep_function_filter = keep_endpoint_metrics(phoenix_endpoints) Event.build( @@ -224,7 +223,9 @@ if Code.ensure_loaded?(Phoenix) do [endpoint] endpoints = Keyword.get(opts, :endpoints) -> - Enum.map(endpoints, fn e -> elem(e, 0) end) + Enum.map(endpoints, fn {endpoint, _settings} -> + endpoint + end) true -> [] @@ -497,7 +498,9 @@ if Code.ensure_loaded?(Phoenix) do |> String.trim_leading("Elixir.") end - defp normalize_module_name(name), do: name + defp normalize_module_name(name) do + String.trim_leading(name, "Elixir.") + end defp normalize_action(action) when is_atom(action), do: action defp normalize_action(_action), do: "Unknown" diff --git a/test/support/metrics/phoenix.txt b/test/support/metrics/phoenix.txt index 352ced3..d7037d1 100644 --- a/test/support/metrics/phoenix.txt +++ b/test/support/metrics/phoenix.txt @@ -6,24 +6,24 @@ web_app_prom_ex_prom_ex_status_info 1 web_app_prom_ex_phoenix_channel_joined_total{endpoint="WebAppWeb.Endpoint",result="ok",transport="websocket"} 17 # HELP web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds The time it takes for the application to respond to channel messages. # TYPE web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds histogram -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="10"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="100"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="500"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="1000"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="5000"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="10000"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="+Inf"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_sum{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Elixir.Phoenix.LiveReloader.Socket"} 0.051792 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_count{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Elixir.Phoenix.LiveReloader.Socket"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="10"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="100"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="500"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="1000"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="5000"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="10000"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Elixir.Phoenix.LiveReloader.Socket",le="+Inf"} 1 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_sum{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Elixir.Phoenix.LiveReloader.Socket"} 0.051792 -web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_count{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Elixir.Phoenix.LiveReloader.Socket"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Phoenix.LiveReloader.Socket",le="10"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Phoenix.LiveReloader.Socket",le="100"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Phoenix.LiveReloader.Socket",le="500"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Phoenix.LiveReloader.Socket",le="1000"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Phoenix.LiveReloader.Socket",le="5000"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Phoenix.LiveReloader.Socket",le="10000"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Phoenix.LiveReloader.Socket",le="+Inf"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_sum{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Phoenix.LiveReloader.Socket"} 0.051792 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_count{endpoint="WebAppWeb.Endpoint",event="test_event",handler="Phoenix.LiveReloader.Socket"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Phoenix.LiveReloader.Socket",le="10"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Phoenix.LiveReloader.Socket",le="100"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Phoenix.LiveReloader.Socket",le="500"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Phoenix.LiveReloader.Socket",le="1000"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Phoenix.LiveReloader.Socket",le="5000"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Phoenix.LiveReloader.Socket",le="10000"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_bucket{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Phoenix.LiveReloader.Socket",le="+Inf"} 1 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_sum{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Phoenix.LiveReloader.Socket"} 0.051792 +web_app_prom_ex_phoenix_channel_handled_in_duration_milliseconds_count{endpoint="WebAppWeb.Endpoint",event="another_test_event",handler="Phoenix.LiveReloader.Socket"} 1 # HELP web_app_prom_ex_phoenix_http_requests_total The number of requests have been serviced. # TYPE web_app_prom_ex_phoenix_http_requests_total counter web_app_prom_ex_phoenix_http_requests_total{action="index",controller="Phoenix.LiveView.Plug",host="localhost",method="GET",path="/",status="500"} 2