Skip to content

Commit

Permalink
Updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akoutmos committed Oct 24, 2024
1 parent 98efa96 commit 115e851
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions lib/prom_ex/plugins/phoenix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 ->
[]
Expand Down Expand Up @@ -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"
Expand Down
36 changes: 18 additions & 18 deletions test/support/metrics/phoenix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 115e851

Please sign in to comment.