AutoIDM / tap-clickup

tap-clickup , singer compliant tap for pulling clickup data
MIT License
12 stars 19 forks source link

Request Retry logic #125

Closed LucasZielke closed 2 years ago

LucasZielke commented 2 years ago

While rare, I got returned a gateway timeout while running the tap, with ongoing bug of slow response times from the clickup api, having some sort of retry logic for this might be a good idea

time=2022-05-19 13:43:09 name=tap-clickup level=INFO message=INFO METRIC: {'type': 'timer', 'metric': 'http_request_duration', 'value': 60.904911, 'tags': {'endpoint': '/api/v2/space/▒▒▒▒▒▒/tag', 'http_status_code': 504, 'status': 'failed', 'context': {'space_id': '▒▒▒▒▒▒▒'}}}
Traceback (most recent call last):
  File "tap_env/lib/python3.8/site-packages/tap-cli.py", line 4, in <module>
    TapClickUp.cli()
  File "/var/task/tap_env/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/var/task/tap_env/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/var/task/tap_env/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/var/task/tap_env/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/var/task/tap_env/lib/python3.8/site-packages/singer_sdk/tap_base.py", line 474, in cli
    tap.sync_all()
  File "/var/task/tap_env/lib/python3.8/site-packages/singer_sdk/tap_base.py", line 343, in sync_all
    stream.sync()
  File "/var/task/tap_env/lib/python3.8/site-packages/singer_sdk/streams/core.py", line 984, in sync
    self._sync_records(context)
  File "/var/task/tap_env/lib/python3.8/site-packages/singer_sdk/streams/core.py", line 927, in _sync_records
    self._sync_children(child_context)
  File "/var/task/tap_env/lib/python3.8/site-packages/tap_clickup/client.py", line 129, in _sync_children
    child_stream.sync(child_stream.from_parent_context(context=child_context))
  File "/var/task/tap_env/lib/python3.8/site-packages/singer_sdk/streams/core.py", line 984, in sync
    self._sync_records(context)
  File "/var/task/tap_env/lib/python3.8/site-packages/singer_sdk/streams/core.py", line 927, in _sync_records
    self._sync_children(child_context)
  File "/var/task/tap_env/lib/python3.8/site-packages/tap_clickup/client.py", line 129, in _sync_children
    child_stream.sync(child_stream.from_parent_context(context=child_context))
  File "/var/task/tap_env/lib/python3.8/site-packages/singer_sdk/streams/core.py", line 984, in sync
    self._sync_records(context)
  File "/var/task/tap_env/lib/python3.8/site-packages/singer_sdk/streams/core.py", line 911, in _sync_records
    for record_result in self.get_records(current_context):
  File "/var/task/tap_env/lib/python3.8/site-packages/singer_sdk/streams/rest.py", line 345, in get_records
    for record in self.request_records(context):
  File "/var/task/tap_env/lib/python3.8/site-packages/singer_sdk/streams/rest.py", line 253, in request_records
    resp = self._request_with_backoff(prepared_request, context)
  File "/var/task/tap_env/lib/python3.8/site-packages/backoff/_sync.py", line 94, in retry
    ret = target(*args, **kwargs)
  File "/var/task/tap_env/lib/python3.8/site-packages/tap_clickup/client.py", line 101, in _request_with_backoff
    raise RuntimeError(
RuntimeError: Error making request to API: https://api.clickup.com/api/v2/space/▒▒▒▒▒▒/tag [504 - b'<html>\r
<head><title>504 Gateway Time-out</title></head>\r
<body>\r
<center><h1>504 Gateway Time-out</h1></center>\r
</body>\r
</html>\r
']
visch commented 2 years ago

For sure, 504's should be retrying already

https://github.com/AutoIDM/tap-clickup/blob/main/tap_clickup/client.py#L105

I wonder if the logs show any retries here or if there's a bug and retries are not happening? Or maybe we are not retrying enough times?

visch commented 2 years ago

@LucasZielke I read through that stack trace a bit closer.

File "/var/task/tap_env/lib/python3.8/site-packages/tap_clickup/client.py", line 101, in _request_with_backoff
    raise RuntimeError(

Line 101 doesn't have that any longer, maybe you're on an old version of tap_clickup?

LucasZielke commented 2 years ago

Ah, thats right, I was using an old version 😅

visch commented 2 years ago

Ah, thats right, I was using an old version 😅

No problem, thanks for putting in an issue anyways!