From 0577f72484ef284ada580a657e097d7c60727e28 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Thu, 15 May 2025 16:14:26 +0100 Subject: [PATCH] Remove Prometheus-based metrics Never use them --- fly.toml | 4 --- lib/music_library_web/endpoint.ex | 2 -- lib/music_library_web/telemetry.ex | 34 ------------------------- lib/music_library_web/telemetry/plug.ex | 22 ---------------- mix.exs | 1 - mix.lock | 1 - 6 files changed, 64 deletions(-) delete mode 100644 lib/music_library_web/telemetry/plug.ex diff --git a/fly.toml b/fly.toml index 469e2203..5254bada 100644 --- a/fly.toml +++ b/fly.toml @@ -40,7 +40,3 @@ soft_limit = 1000 memory = '512mb' cpu_kind = 'shared' cpus = 1 - -[metrics] -path = "/metrics" -port = 8080 diff --git a/lib/music_library_web/endpoint.ex b/lib/music_library_web/endpoint.ex index 32ead83f..2da38fb6 100644 --- a/lib/music_library_web/endpoint.ex +++ b/lib/music_library_web/endpoint.ex @@ -15,8 +15,6 @@ defmodule MusicLibraryWeb.Endpoint do encrypt: true ] - plug MusicLibraryWeb.Telemetry.Plug, at: "/metrics" - socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]], longpoll: [connect_info: [session: @session_options]] diff --git a/lib/music_library_web/telemetry.ex b/lib/music_library_web/telemetry.ex index 1c399539..6337fe0d 100644 --- a/lib/music_library_web/telemetry.ex +++ b/lib/music_library_web/telemetry.ex @@ -10,7 +10,6 @@ defmodule MusicLibraryWeb.Telemetry do def init(_arg) do children = [ {MusicLibraryWeb.Telemetry.Storage, metrics()}, - {TelemetryMetricsPrometheus.Core, [metrics: prometheus_metrics()]}, # Telemetry poller will execute the given period measurements # every 10_000ms. Learn more here: https://hexdocs.pm/telemetry_metrics {:telemetry_poller, measurements: periodic_measurements(), period: 10_000} @@ -104,39 +103,6 @@ defmodule MusicLibraryWeb.Telemetry do ] end - def prometheus_metrics do - [ - # VM Metrics - last_value("vm.memory.total", unit: {:byte, :megabyte}), - last_value("vm.total_run_queue_lengths.total"), - last_value("vm.total_run_queue_lengths.cpu"), - last_value("vm.total_run_queue_lengths.io"), - - # Database Metrics - last_value("music_library.repo.query.total_time", - unit: {:native, :millisecond}, - description: "The sum of the other measurements" - ), - last_value("music_library.repo.query.decode_time", - unit: {:native, :millisecond}, - description: "The time spent decoding the data received from the database" - ), - last_value("music_library.repo.query.query_time", - unit: {:native, :millisecond}, - description: "The time spent executing the query" - ), - last_value("music_library.repo.query.queue_time", - unit: {:native, :millisecond}, - description: "The time spent waiting for a database connection" - ), - last_value("music_library.repo.query.idle_time", - unit: {:native, :millisecond}, - description: - "The time the connection spent waiting before being checked out for the query" - ) - ] - end - defp periodic_measurements do [ # A module, function and arguments to be invoked periodically. diff --git a/lib/music_library_web/telemetry/plug.ex b/lib/music_library_web/telemetry/plug.ex deleted file mode 100644 index 9625eca9..00000000 --- a/lib/music_library_web/telemetry/plug.ex +++ /dev/null @@ -1,22 +0,0 @@ -defmodule MusicLibraryWeb.Telemetry.Plug do - @behaviour Plug - - import Plug.Conn - - def init(opts) do - Keyword.validate!(opts, [:at]) - end - - def call(conn, opts) do - at = Keyword.fetch!(opts, :at) - - if conn.request_path == at do - conn - |> put_resp_content_type("text/plain") - |> send_resp(200, TelemetryMetricsPrometheus.Core.scrape()) - |> halt() - else - conn - end - end -end diff --git a/mix.exs b/mix.exs index ccc83884..0662bd9d 100644 --- a/mix.exs +++ b/mix.exs @@ -101,7 +101,6 @@ defmodule MusicLibrary.MixProject do # Prod error/perf tooling {:phoenix_live_dashboard, "~> 0.8.3"}, - {:telemetry_metrics_prometheus_core, "~> 1.2"}, {:error_tracker, "~> 0.6.0"}, {:recon, "~> 2.5"}, {:telemetry_metrics, "~> 1.0"}, diff --git a/mix.lock b/mix.lock index a520b807..a4ef6f47 100644 --- a/mix.lock +++ b/mix.lock @@ -55,7 +55,6 @@ "tailwind": {:hex, :tailwind, "0.3.1", "a89d2835c580748c7a975ad7dd3f2ea5e63216dc16d44f9df492fbd12c094bed", [:mix], [], "hexpm", "98a45febdf4a87bc26682e1171acdedd6317d0919953c353fcd1b4f9f4b676a2"}, "telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"}, "telemetry_metrics": {:hex, :telemetry_metrics, "1.1.0", "5bd5f3b5637e0abea0426b947e3ce5dd304f8b3bc6617039e2b5a008adc02f8f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e7b79e8ddfde70adb6db8a6623d1778ec66401f366e9a8f5dd0955c56bc8ce67"}, - "telemetry_metrics_prometheus_core": {:hex, :telemetry_metrics_prometheus_core, "1.2.1", "c9755987d7b959b557084e6990990cb96a50d6482c683fb9622a63837f3cd3d8", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6 or ~> 1.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "5e2c599da4983c4f88a33e9571f1458bf98b0cf6ba930f1dc3a6e8cf45d5afb6"}, "telemetry_poller": {:hex, :telemetry_poller, "1.2.0", "ba82e333215aed9dd2096f93bd1d13ae89d249f82760fcada0850ba33bac154b", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7216e21a6c326eb9aa44328028c34e9fd348fb53667ca837be59d0aa2a0156e8"}, "thousand_island": {:hex, :thousand_island, "1.3.13", "d598c609172275f7b1648c9f6eddf900e42312b09bfc2f2020358f926ee00d39", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "5a34bdf24ae2f965ddf7ba1a416f3111cfe7df50de8d66f6310e01fc2e80b02a"}, "tidewave": {:hex, :tidewave, "0.1.6", "f07514ee2c348c2e682a2632309ac6d8ec425392bfb803955a6bb19ca5508e2f", [:mix], [{:circular_buffer, "~> 0.4", [hex: :circular_buffer, repo: "hexpm", optional: false]}, {:igniter, ">= 0.5.47 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:plug, "~> 1.17", [hex: :plug, repo: "hexpm", optional: false]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}], "hexpm", "3708592f325e1f54b99b215cd8c38f726732451bf5cfa16d73584793f99d9da4"},