Add HTTP Metrics for Last.Fm and MusicBrainz

This commit is contained in:
Claudio Ortolina
2024-11-25 10:03:34 +00:00
parent edb24dc932
commit b5400b76fc
+52
View File
@@ -75,6 +75,46 @@ defmodule MusicLibraryWeb.Telemetry do
"The time the connection spent waiting before being checked out for the query" "The time the connection spent waiting before being checked out for the query"
), ),
# LastFm HTTP Metrics
summary("finch.request.stop.duration",
unit: {:native, :millisecond},
tags: [:normalized_path],
tag_values: &add_normalized_path/1,
keep: &keep_last_fm/1,
reporter_options: [
nav: "HTTP - Last.fm"
]
),
summary("finch.response.stop.duration",
unit: {:native, :millisecond},
tags: [:normalized_path],
tag_values: &add_normalized_path/1,
keep: &keep_last_fm/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"
]
),
# VM Metrics # VM Metrics
summary("vm.memory.total", unit: {:byte, :kilobyte}), summary("vm.memory.total", unit: {:byte, :kilobyte}),
summary("vm.total_run_queue_lengths.total"), summary("vm.total_run_queue_lengths.total"),
@@ -90,4 +130,16 @@ defmodule MusicLibraryWeb.Telemetry do
# {MusicLibraryWeb, :count_users, []} # {MusicLibraryWeb, :count_users, []}
] ]
end end
defp add_normalized_path(metadata) do
Map.put(metadata, :normalized_path, URI.parse(metadata.request.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"
end
end end