diff --git a/swh/core/github/tests/test_github_utils.py b/swh/core/github/tests/test_github_utils.py --- a/swh/core/github/tests/test_github_utils.py +++ b/swh/core/github/tests/test_github_utils.py @@ -163,7 +163,7 @@ call("responses_total", "c", 1, tags0, 1), call("remaining_requests", "g", 999, {"username": username0}, 1), call("rate_limited_responses_total", "c", 1, {"username": username0}, 1), - call("sleep", "c", 1, None, 1), + call("sleep_seconds_total", "c", 1, None, 1), call("requests_total", "c", 1, {"username": username1}, 1), call("responses_total", "c", 1, tags1, 1), call("remaining_requests", "g", 998, {"username": username1}, 1), @@ -253,7 +253,7 @@ call("remaining_requests", "g", 0, {"username": user}, 1), call("reset_seconds", "g", ratelimit_reset, {"username": user}, 1), call("rate_limited_responses_total", "c", 1, {"username": user}, 1), - call("sleep", "c", 1, None, 1), + call("sleep_seconds_total", "c", 1, None, 1), ] expected_calls_groups = ( @@ -268,7 +268,7 @@ ] # And finally, a long sleep and the successful request + [ - [call("sleep", "c", ratelimit_reset + 1, None, 1)], + [call("sleep_seconds_total", "c", ratelimit_reset + 1, None, 1)], ok_request_calls( github_session.credentials[num_ratelimit % len(github_credentials)][ "username" @@ -338,7 +338,7 @@ call("remaining_requests", "g", 0, {"username": user}, 1), call("reset_seconds", "g", ratelimit_reset, {"username": user}, 1), call("rate_limited_responses_total", "c", 1, {"username": user}, 1), - call("sleep", "c", ratelimit_reset + 1, None, 1), + call("sleep_seconds_total", "c", ratelimit_reset + 1, None, 1), ] expected_calls_groups = ( diff --git a/swh/core/github/utils.py b/swh/core/github/utils.py --- a/swh/core/github/utils.py +++ b/swh/core/github/utils.py @@ -232,7 +232,7 @@ # Use next token in line self.set_next_session_token() # Wait one second to avoid triggering GitHub's abuse rate limits - self.statsd.increment("sleep", 1) + self.statsd.increment("sleep_seconds_total", 1) time.sleep(1) # All tokens have been rate-limited. What do we do? @@ -249,7 +249,7 @@ "Rate limits exhausted for all tokens. Sleeping for %f seconds.", sleep_time, ) - self.statsd.increment("sleep", sleep_time) + self.statsd.increment("sleep_seconds_total", sleep_time) time.sleep(sleep_time) def get_canonical_url(self, url: str) -> Optional[str]: