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
This commit is contained in:
Claudio Ortolina
2024-11-25 10:23:31 +00:00
parent 415312b98b
commit c93cf6a406
+19 -38
View File
@@ -75,48 +75,28 @@ 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 # HTTP Metrics
summary("finch.request.stop.duration", summary("finch.request.stop.duration",
unit: {:native, :millisecond}, unit: {:native, :millisecond},
tags: [:normalized_path], tags: [:normalized_path],
tag_values: &add_normalized_path/1, tag_values: &add_tags/1,
keep: &keep_last_fm/1, drop: &drop_archive_requests/1,
reporter_options: [ reporter_options: [
nav: "HTTP - Last.fm" nav: "HTTP"
] ]
), ),
summary("finch.response.stop.duration", summary("finch.request.stop.duration",
unit: {:native, :millisecond}, unit: {:native, :millisecond},
tags: [:normalized_path], tags: [:host],
tag_values: &add_normalized_path/1, tag_values: &add_tags/1,
keep: &keep_last_fm/1, drop: &drop_archive_requests/1,
reporter_options: [ reporter_options: [
nav: "HTTP - Last.fm" nav: "HTTP"
]
),
# 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, :megabyte}),
summary("vm.total_run_queue_lengths.total"), summary("vm.total_run_queue_lengths.total"),
summary("vm.total_run_queue_lengths.cpu"), summary("vm.total_run_queue_lengths.cpu"),
summary("vm.total_run_queue_lengths.io") summary("vm.total_run_queue_lengths.io")
@@ -131,15 +111,16 @@ defmodule MusicLibraryWeb.Telemetry do
] ]
end end
defp add_normalized_path(metadata) do defp add_tags(metadata) do
Map.put(metadata, :normalized_path, URI.parse(metadata.request.path).path) req = metadata.request
Map.merge(metadata, %{
host: req.host,
normalized_path: URI.parse(req.path).path
})
end end
defp keep_last_fm(metadata) do defp drop_archive_requests(metadata) do
metadata.request.host == "ws.audioscrobbler.com" metadata.request.host =~ "archive.org"
end
defp keep_musicbrainz(metadata) do
metadata.request.host == "musicbrainz.org"
end end
end end