Retry mechanism behaves incorrectly when HTTP 429 is returned by Datadog
Maintainer antworten meist innerhalb von 2 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
Beginne damit, nachzuverfolgen, wie die Option enable_retry HTTP-429-Antworten im Client verarbeitet, und verwende dabei die im Issue beschriebene Sequenz zum Abrufen des Dashboards sowie die retry-bezogenen Tests. Reproduziere den Rate-Limit-Fall und überprüfe, dass der Client vor dem erneuten Versuch auf x-ratelimit-reset wartet, anstatt beim ersten 429 zu beenden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
Summary:
Script which fetches all dashboards in the loop exits with an error, when rate limit runs out, even though enable_retry option is turned on. According to debug logs, script exits on first HTTP 429 returned, with no retry attempted.
Details:
We have a script, which runs every night to fetch all dashboards from Datadog. It does it by fetching list of dashboards, and then goes one after another to fetch details of each one. After number of our dashboard grew, we have run into HTTP 429 errors due to Datadog's rate limit.
We decided to use retry option, which is built into the library since 2.16.0, but it seems it's not ready to how Datadog responds in case of hitting rate limit.
When I started the script in a loop with debug option enabled I see that Datadog returns HTTP 200 up until the moment when rate limit is reached, then next request gets HTTP 429 (API Keys removed from logs below):
# normal request before rate limit runs out
send: b'GET /api/v1/dashboard/<id-of-dashboard-59> Host: us5.datadoghq.com Accept-Encoding: gzip User-Agent: datadog-api-client-python/2.23.0
reply: 'HTTP/1.1 200 OK'
...
header: content-encoding: gzip
header: x-ratelimit-limit: 60
header: x-ratelimit-period: 60
header: x-ratelimit-remaining: 1
header: x-ratelimit-reset: 29
header: x-ratelimit-name: dashboards_get_custom_api
# normal request, last one within the limits
send: b'GET /api/v1/dashboard/<id-of-dashboard-60> Host: us5.datadoghq.com Accept-Encoding: gzip User-Agent: datadog-api-client-python/2.23.0
reply: 'HTTP/1.1 200 OK'
...
header: content-encoding: gzip
header: x-ratelimit-limit: 60
header: x-ratelimit-period: 60
header: x-ratelimit-remaining: 0
header: x-ratelimit-reset: 28
header: x-ratelimit-name: dashboards_get_custom_api
# next request, this one gets HTTP 429
send: b'GET /api/v1/dashboard/<id-of-dashboard-61> Host: us5.datadoghq.com Accept-Encoding: gzip User-Agent: datadog-api-client-python/2.23.0
reply: 'HTTP/1.1 429 Too Many Requests'
...
header: x-ratelimit-limit: 60
header: x-ratelimit-period: 60
header: x-ratelimit-remaining: 0
header: x-ratelimit-reset: 28
header: x-ratelimit-name: dashboards_get_custom_api
# and at this point script fails with
Error: (429)
Reason: Too Many Requests
HTTP response headers: {'x-ratelimit-limit': '60', 'x-ratelimit-period': '60', 'x-ratelimit-remaining': '0', 'x-ratelimit-reset': '28', 'x-ratelimit-name': 'dashboards_get_custom_api', 'content-type': 'application/json', 'Content-Length': '183', 'x-content-type-options': 'nosniff', 'strict-transport-security': 'max-age=31536000; includeSubDomains; preload', 'date': 'Mon, 25 Mar 2024 09:05:32 GMT', 'Via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000'}
HTTP response body: {'status': 'error', 'code': 429, 'errors': ['Too many requests'], 'statuspage': 'http://status.us5.datadoghq.com', 'twitter': 'http://twitter.com/datadogops', 'email': '[email protected]'}
To Reproduce
See description above
Expected behavior
I expect library to sleep for x-ratelimit-reset time, just like it's described in tests, which introduced this functionality. Right now I need to add a sleep between requests to API as a workaround
Screenshots
N/A - logs attached
Environment and Versions (please complete the following information):
client library version 2.23.0
Additional context
Add any other context about the problem here.
- Vorherrschende Sprache
- Python
- Sterne
- 167
- Forks
- 55
- Ø Merge
- 3 T. 17 Std.
- Gemergte PRs (30 T.)
- 80
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus DataDog/datadog-api-client-python
-
Python 3.13/3.14 SyntaxWarning in v1 LogsPipelinesApi docstringEvtl. vergeben @Mirochill hat das vor 142 Tagen übernommen. Offenstale
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 72/100
DataDog/datadog-api-client-python#3535 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
kind/bug stale
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 66/100
DataDog/datadog-api-client-python#3717 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
kind/bug stale
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 75/100
DataDog/datadog-api-client-python#3656 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
kind/bug stale
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 38/100
DataDog/datadog-api-client-python#3120 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
stale
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
DataDog/datadog-api-client-python#2986 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in DataDog/datadog-api-client-python
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
NousResearch/hermes-agent#136483 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] LazyStackedTensorDictStore zeroes the last byte of a new key set on the last elementEvtl. vergeben @peterdsharpe hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
pytorch/tensordict#2307 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
GrokModel.generate/a_generate pass an OpenAI-style list-of-dicts to xai_sdk.chat.user(), so every call crashes with a protobuf TypeError before any network I/OEvtl. vergeben @Christian-Sidak hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
confident-ai/deepeval#3436 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag