Skip to content

feat: Use retry http and add backoff#151

Merged
tshe-te merged 4 commits into
v3from
CP-2701
Oct 14, 2025
Merged

feat: Use retry http and add backoff#151
tshe-te merged 4 commits into
v3from
CP-2701

Conversation

@tshe-te

@tshe-te tshe-te commented Oct 8, 2025

Copy link
Copy Markdown

Reference: https://github.com/thousandeyes/thousandeyes-sdk-python/pull/7/files

Test locally by sending over 200 requests at the same time, which received 429s when reaching the rate limit without the change. All requests received 200 after the change was applied:
Screenshot 2025-10-08 at 10 25 19

Locally terraform provider applied thousandeyes resources successfully waiting for rate limit to be reset:
Before

tshe@TSHE-M-KXTG base % terraform plan
data.thousandeyes_agent.neth_ams: Reading...

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: 429 Too Many Requests
│ 
│   with data.thousandeyes_agent.neth_ams,
│   on example.tf line 1, in data "thousandeyes_agent" "neth_ams":
│    1: data "thousandeyes_agent" "neth_ams" {
│ 

After

tshe@TSHE-M-KXTG base % terraform plan
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - thousandeyes/thousandeyes in /Users/tshe/LocalRepo/terraform-provider-thousandeyes
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the
│ state to become incompatible with published releases.
╵
data.thousandeyes_agent.neth_ams: Reading...
data.thousandeyes_agent.neth_ams: Still reading... [10s elapsed]
data.thousandeyes_agent.neth_ams: Still reading... [20s elapsed]
data.thousandeyes_agent.neth_ams: Still reading... [30s elapsed]
data.thousandeyes_agent.neth_ams: Still reading... [40s elapsed]
data.thousandeyes_agent.neth_ams: Read complete after 48s [id=19]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with
the following symbols:
  + create

Terraform will perform the following actions:

Comment thread client/backoffs.go
Comment thread client/client.go

func NewRetryAPIClient() *http.Client {
var retryClient = retryablehttp.NewClient()
retryClient.Backoff = thousandEyesBackoff

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't set up RetryMax so the client will attempt 5 times as the default.

Comment thread client/backoffs.go
)

// Custom backoff function
func thousandEyesBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function has the same logic as the python SDK which respects Retry-After first then checks thousandeyes headers. https://github.com/thousandeyes/thousandeyes-sdk-python/pull/7/files#diff-8587054108c7902eac148f3b9ea7a213f04ddebde0be29f8b68affe61b98b39fR46

@phpinhei-te phpinhei-te left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its ok to have ur branch with the internal ticket number, but the PR name shouldnt contain it.
prefix it with feature: since its a new feature included

Also, do you mind testing this with the terraform provider before we proceed with actually merging/tagging, etc?

@tshe-te tshe-te changed the title CP-2701: Use retry http and add backoff feature: Use retry http and add backoff Oct 10, 2025
@tshe-te tshe-te changed the title feature: Use retry http and add backoff feat.: Use retry http and add backoff Oct 10, 2025
@tshe-te tshe-te changed the title feat.: Use retry http and add backoff feat: Use retry http and add backoff Oct 10, 2025
@tshe-te

tshe-te commented Oct 10, 2025

Copy link
Copy Markdown
Author

@tshe-te
tshe-te merged commit bb1217f into v3 Oct 14, 2025
1 check passed
@tshe-te
tshe-te deleted the CP-2701 branch October 14, 2025 09:25
@mpragosa-te mpragosa-te mentioned this pull request Oct 17, 2025
@mpragosa-te mpragosa-te mentioned this pull request Nov 6, 2025
This was referenced Nov 25, 2025
This was referenced Dec 11, 2025
@mpragosa-te mpragosa-te mentioned this pull request Dec 19, 2025
@mpragosa-te mpragosa-te mentioned this pull request Jan 8, 2026
This was referenced Feb 5, 2026
This was referenced Feb 27, 2026
This was referenced Mar 10, 2026
@mpragosa-te mpragosa-te mentioned this pull request Apr 2, 2026
This was referenced Apr 15, 2026
This was referenced Apr 30, 2026
This was referenced May 13, 2026
This was referenced May 28, 2026
@mpragosa-te mpragosa-te mentioned this pull request Jun 11, 2026
This was referenced Jun 19, 2026
@mpragosa-te mpragosa-te mentioned this pull request Jul 1, 2026
@mpragosa-te mpragosa-te mentioned this pull request Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants