Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry connection errors #214

Merged
merged 3 commits into from
May 27, 2024
Merged

Retry connection errors #214

merged 3 commits into from
May 27, 2024

Conversation

alexmojaki
Copy link
Contributor

After some investigation, I've found that neither OTEL nor requests does any retrying by default when there's a connection or timeout error while making a request.

OTEL does retry on certain status codes in a way that looks sensible so I'm leaving that case as is, although it's not the kind of problem we usually see.

It's possible to configure retries with requests but OTEL doesn't do so and it didn't seem easier than just coding the retries myself.

@alexmojaki alexmojaki requested a review from adriangb May 27, 2024 14:37
Copy link

codecov bot commented May 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link

cloudflare-workers-and-pages bot commented May 27, 2024

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 10c81e2
Status: ✅  Deploy successful!
Preview URL: https://d8389f62.logfire-docs.pages.dev
Branch Preview URL: https://alex-retry-connection-errors.logfire-docs.pages.dev

View logs

@@ -38,7 +41,20 @@ def gen() -> Iterable[bytes]:
yield chunk

request.body = gen() # type: ignore
return super().send(request, **kwargs)

max_attempts = 7
Copy link
Member

Choose a reason for hiding this comment

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

Should this be configurable in any way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. Making it configurable would be painful with little benefit, and OTEL's retrying of status codes isn't configurable.

@alexmojaki alexmojaki merged commit b202619 into main May 27, 2024
12 checks passed
@alexmojaki alexmojaki deleted the alex/retry-connection-errors branch May 27, 2024 14:50
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.

2 participants