Add metrics to rate limiter

This commit is contained in:
Claudio Ortolina
2026-03-02 19:23:27 +00:00
parent c066585cbf
commit 6ef5f0a000
3 changed files with 66 additions and 0 deletions
+10
View File
@@ -69,6 +69,16 @@ defmodule MusicLibraryWeb.Telemetry do
]
),
# Rate Limiter
summary("req.rate_limiter.throttle.sleep_ms",
unit: :millisecond,
description: "Time spent waiting for rate limit cooldown",
tags: [:name],
reporter_options: [
nav: "External APIs"
]
),
# Assets
summary("music_library.assets.cache_size",
unit: {:byte, :kilobyte},
+6
View File
@@ -56,6 +56,12 @@ defmodule Req.RateLimiter do
remaining = cooldown - elapsed
if remaining > 0 do
:telemetry.execute(
[:req, :rate_limiter, :throttle],
%{sleep_ms: remaining},
%{name: name}
)
Process.sleep(remaining)
end