From 254c99c33daf56bbeb1eda11929406144571d99b Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sat, 20 Sep 2025 10:29:31 +0300 Subject: [PATCH] Reorganize metrics Disable all Phoenix metrics - while useful in theory, I never got any specific insight from any of them. --- lib/music_library_web/telemetry.ex | 94 +++++++----------------------- 1 file changed, 22 insertions(+), 72 deletions(-) diff --git a/lib/music_library_web/telemetry.ex b/lib/music_library_web/telemetry.ex index 9f561b53..f69f8832 100644 --- a/lib/music_library_web/telemetry.ex +++ b/lib/music_library_web/telemetry.ex @@ -23,76 +23,27 @@ defmodule MusicLibraryWeb.Telemetry do def metrics do [ - # Phoenix Metrics - summary("phoenix.endpoint.stop.duration", - unit: {:native, :millisecond} - ), - summary("phoenix.router_dispatch.stop.duration", - tags: [:route], - unit: {:native, :millisecond} - ), - summary("phoenix.socket_connected.duration", - unit: {:native, :millisecond} - ), - summary("phoenix.channel_joined.duration", - unit: {:native, :millisecond} - ), - summary("phoenix.channel_handled_in.duration", - tags: [:event], - unit: {:native, :millisecond} - ), - - # LiveView Metrics - summary("phoenix.live_view.mount.stop.duration", - unit: {:native, :millisecond}, - tags: [:view] - ), - summary("phoenix.live_view.handle_params.stop.duration", - unit: {:native, :millisecond}, - tags: [:view] - ), - summary("phoenix.live_view.handle_event.stop.duration", - unit: {:native, :millisecond}, - tags: [:view, :event] - ), - summary("phoenix.live_view.render.stop.duration", - unit: {:native, :millisecond}, - tags: [:view] - ), - - # LiveComponent Metrics - summary("phoenix.live_component.update.stop.duration", - unit: {:native, :millisecond}, - tags: [:component], - drop: &drop_live_dashboard_events/1 - ), - summary("phoenix.live_component.handle_event.stop.duration", - unit: {:native, :millisecond}, - tags: [:component, :event], - drop: &drop_live_dashboard_events/1 - ), - # Database Metrics summary("music_library.repo.query.total_time", unit: {:native, :millisecond}, - description: "The sum of the other measurements" - ), - summary("music_library.repo.query.decode_time", - unit: {:native, :millisecond}, - description: "The time spent decoding the data received from the database" + description: "The sum of the other measurements", + reporter_options: [ + nav: "Repo" + ] ), summary("music_library.repo.query.query_time", unit: {:native, :millisecond}, - description: "The time spent executing the query" + description: "The time spent executing the query", + reporter_options: [ + nav: "Repo" + ] ), summary("music_library.repo.query.queue_time", unit: {:native, :millisecond}, - description: "The time spent waiting for a database connection" - ), - summary("music_library.repo.query.idle_time", - unit: {:native, :millisecond}, - description: - "The time the connection spent waiting before being checked out for the query" + description: "The time spent waiting for a database connection", + reporter_options: [ + nav: "Repo" + ] ), # HTTP Metrics @@ -102,7 +53,7 @@ defmodule MusicLibraryWeb.Telemetry do tag_values: &add_tags/1, drop: &drop_archive_requests/1, reporter_options: [ - nav: "HTTP" + nav: "External APIs" ] ), summary("finch.request.stop.duration", @@ -111,13 +62,19 @@ defmodule MusicLibraryWeb.Telemetry do tag_values: &add_tags/1, drop: &drop_archive_requests/1, reporter_options: [ - nav: "HTTP" + nav: "External APIs" ] ), # Assets - summary("music_library.assets.cache_size", unit: {:byte, :kilobyte}), - summary("music_library.assets.content_size", unit: {:byte, :megabyte}), + summary("music_library.assets.cache_size", + unit: {:byte, :kilobyte}, + reporter_options: [nav: "Assets"] + ), + summary("music_library.assets.content_size", + unit: {:byte, :megabyte}, + reporter_options: [nav: "Assets"] + ), # VM Metrics summary("vm.memory.total", unit: {:byte, :megabyte}), @@ -149,11 +106,4 @@ defmodule MusicLibraryWeb.Telemetry do defp drop_archive_requests(metadata) do metadata.request.host =~ "archive.org" end - - defp drop_live_dashboard_events(metadata) do - case Module.split(metadata.component) do - ["Phoenix" | _rest] -> true - _ -> false - end - end end