GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Refine delay jitter for exponential backoff by YuriyHolinko · Pull Request #7206 · open-telemetry/opentelemetry-java

Conversation

@YuriyHolinko

@YuriyHolinko YuriyHolinko commented Mar 17, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Adjusted the jitter calculation to improve the randomness and distribution of delays in the exponential backoff logic.

current implementation is not based on exponential backoff but more uses randomly generated numbers in range (0, upperBound) and only upperBound exponentially grows, so in some cases we generate relatively low delays for retries
Also there was an existing link
image

https://github.com/grpc/proposal/blob/master/A6-client-retries.md#exponential-backoff in code to implementation of exponential backoff but actual source code was different

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@YuriyHolinko
Refine delay jitter for exponential backoff
df10b75
@YuriyHolinko
YuriyHolinko requested a review from a team as a code owner March 17, 2025 15:11
@codecov

codecov Bot commented Mar 17, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.93%. Comparing base (490173b) to head (2fe22d8).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7206   +/-   ##
=========================================
  Coverage     89.93%   89.93%           
- Complexity     6676     6678    +2     
=========================================
  Files           750      750           
  Lines         20168    20176    +8     
  Branches       1978     1978           
=========================================
+ Hits          18138    18146    +8     
  Misses         1435     1435           
  Partials        595      595           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jack-berg

jack-berg commented Mar 17, 2025

Copy link
Copy Markdown
Member

Is this fixing the problem discussed in #7004?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@YuriyHolinko

YuriyHolinko commented Mar 17, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Is this fixing the problem discussed in #7004?

yeah, looks like it's the same issue
i did not think someone else suffers from it, but as we have a few users then it will be very useful feature/bug fix

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@YuriyHolinko
added test
a12b804
jack-berg
jack-berg reviewed Mar 20, 2025
View reviewed changes

@jack-berg jack-berg left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The new logic for computing backoff looks good. Just wondering why touch the other logic, which needs to be pretty carefully considered.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread .../okhttp/src/main/java/io/opentelemetry/exporter/sender/okhttp/internal/RetryInterceptor.java
long currentBackoffNanos =
Math.min(nextBackoffNanos, retryPolicy.getMaxBackoff().toNanos());
long backoffNanos = (long) (randomJitter.get() * currentBackoffNanos);
nextBackoffNanos = (long) (currentBackoffNanos * retryPolicy.getBackoffMultiplier());

@jack-berg jack-berg Mar 20, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Should also update the implementation in JdkHttpSender.

I know its not ideal that there are two implementations.. Maybe worth adding a utility function to RetryPolicy that computes the backoff for a given attempt N. Signature might look like:

public long computeBackoffNanosForAttempt(int attempt, Random randomSource) {...}

It wouldn't be as efficient as the current implementation, but...

  • its such a tiny amount of compute that who cares
  • the compute is trivial compared to the overall cost of preparing and executing and HTTP request

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@YuriyHolinko YuriyHolinko Mar 20, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks, Added code for JdkHttpSender

I did not consider adding that method to calculate a backoff delay time
looking at the code I would say we can build more abstractions for sending requests and checking responses and exceptions, but not sure it's really helpful so let's probably move on with duplicated approach as we had before

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread .../okhttp/src/main/java/io/opentelemetry/exporter/sender/okhttp/internal/RetryInterceptor.java
attempt++;
try {
response = chain.proceed(chain.request());
if (response != null) {

@jack-berg jack-berg Mar 20, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

What's the motivation for changing this part of the logic?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@YuriyHolinko YuriyHolinko Mar 20, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

if response is null and no exception happened, the code fails in throw exception; line because exception is null. when response is null it's not something transient

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jack-berg jack-berg Mar 20, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I suppose this is possible but I haven't seen response null in practice. If it does occur, we can simply add a null check immediately after response = chain.proceed(chain.request()).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@YuriyHolinko YuriyHolinko Mar 20, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

it's exactly what I did in this PR 😃
also null check was before this change so I intentionally keep it (but I suspect I can just drop it)

also previous code has the issue - if previous(before last) attempt returned rertryable response but the last attempt gets retryable exception method still returns the previous response which is not good as the last state (exception) should be returned

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jack-berg reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
YuriyHolinko added 2 commits March 21, 2025 00:41
@YuriyHolinko
added delay backoff logic for jdk http sender
5f1bbb0
@YuriyHolinko
tiny change of local variable usage
2fe22d8
@YuriyHolinko

YuriyHolinko commented Mar 20, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

The new logic for computing backoff looks good. Just wondering why touch the other logic, which needs to be pretty carefully considered.

I replied in threads, tell me please if there are still any unanswered questions

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jack-berg
jack-berg approved these changes Mar 25, 2025
View reviewed changes
@jack-berg

jack-berg commented Mar 25, 2025

Copy link
Copy Markdown
Member

Thanks!

YuriyHolinko reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jack-berg jack-berg mentioned this pull request Mar 25, 2025
Fix Retry time in Exporter #7004
Closed
@jack-berg
jack-berg merged commit 3c12e3a into open-telemetry:main Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jack-berg jack-berg jack-berg approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@YuriyHolinko @jack-berg
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.