From c93cf6a406002bacf42131e27506230352785006 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 25 Nov 2024 10:23:31 +0000 Subject: [PATCH] Group HTTP Metrics - Remove wrong Finch metric name - Filter archive requests due to redirect hostnames (better to track it as a single metrics) - Don't apply competing filter functions - it seems to trip Telemetry Metrics off, and skip the last defined summary --- lib/music_library_web/telemetry.ex | 57 ++++++++++-------------------- 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/lib/music_library_web/telemetry.ex b/lib/music_library_web/telemetry.ex index cc802139..6337fe0d 100644 --- a/lib/music_library_web/telemetry.ex +++ b/lib/music_library_web/telemetry.ex @@ -75,48 +75,28 @@ defmodule MusicLibraryWeb.Telemetry do "The time the connection spent waiting before being checked out for the query" ), - # LastFm HTTP Metrics + # HTTP Metrics summary("finch.request.stop.duration", unit: {:native, :millisecond}, tags: [:normalized_path], - tag_values: &add_normalized_path/1, - keep: &keep_last_fm/1, + tag_values: &add_tags/1, + drop: &drop_archive_requests/1, reporter_options: [ - nav: "HTTP - Last.fm" + nav: "HTTP" ] ), - summary("finch.response.stop.duration", + summary("finch.request.stop.duration", unit: {:native, :millisecond}, - tags: [:normalized_path], - tag_values: &add_normalized_path/1, - keep: &keep_last_fm/1, + tags: [:host], + tag_values: &add_tags/1, + drop: &drop_archive_requests/1, reporter_options: [ - nav: "HTTP - Last.fm" - ] - ), - - # MusicBrainz HTTP Metrics - summary("finch.request.start.duration", - unit: {:native, :millisecond}, - tags: [:normalized_path], - tag_values: &add_normalized_path/1, - keep: &keep_musicbrainz/1, - reporter_options: [ - nav: "HTTP - MusicBrainz" - ] - ), - summary("finch.response.stop.duration", - unit: {:native, :millisecond}, - tags: [:normalized_path], - tag_values: &add_normalized_path/1, - keep: &keep_musicbrainz/1, - reporter_options: [ - nav: "HTTP - MusicBrainz" + nav: "HTTP" ] ), # VM Metrics - summary("vm.memory.total", unit: {:byte, :kilobyte}), + summary("vm.memory.total", unit: {:byte, :megabyte}), summary("vm.total_run_queue_lengths.total"), summary("vm.total_run_queue_lengths.cpu"), summary("vm.total_run_queue_lengths.io") @@ -131,15 +111,16 @@ defmodule MusicLibraryWeb.Telemetry do ] end - defp add_normalized_path(metadata) do - Map.put(metadata, :normalized_path, URI.parse(metadata.request.path).path) + defp add_tags(metadata) do + req = metadata.request + + Map.merge(metadata, %{ + host: req.host, + normalized_path: URI.parse(req.path).path + }) end - defp keep_last_fm(metadata) do - metadata.request.host == "ws.audioscrobbler.com" - end - - defp keep_musicbrainz(metadata) do - metadata.request.host == "musicbrainz.org" + defp drop_archive_requests(metadata) do + metadata.request.host =~ "archive.org" end end