Remove Prometheus-based metrics
Never use them
This commit is contained in:
@@ -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]]
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user