Skip to content

Add a header to count retried remote write requests#12729

Merged
bboreham merged 5 commits intoprometheus:mainfrom
tpaschalis:add-retry-count-header
Sep 20, 2023
Merged

Add a header to count retried remote write requests#12729
bboreham merged 5 commits intoprometheus:mainfrom
tpaschalis:add-retry-count-header

Conversation

@tpaschalis
Copy link
Copy Markdown
Contributor

Similar to how we set the HTTPResendCount attribute in the tracing span whenever sending a remote write batch, we could add a new header for retried requests, identifying the current attempt number.

This would allow remote write backends to more intelligently respond to requests with a proper Retry-After header (eg. #12677).

In case we don't want to alter the Store interface, we can pass the attempt number as a value through the context as well.

Signed-off-by: Marc Tuduri <marctc@protonmail.com>
Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
Copy link
Copy Markdown
Member

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

Seems legit.

httpReq.Header.Set("User-Agent", UserAgent)
httpReq.Header.Set("X-Prometheus-Remote-Write-Version", "0.1.0")
if attempt > 0 {
httpReq.Header.Set("X-Retry-Count", strconv.Itoa(attempt))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AFAICT this isn't an official HTTP spec header right? If not, what do you think of calling it X-Retry-Attempt? To me, count here implies the remaining count of retries before we would give up.

Lets make sure we document the new retry options as part of the 1.1 spec. We should probably also define the header names via constants at some point.

Copy link
Copy Markdown
Contributor Author

@tpaschalis tpaschalis Sep 5, 2023

Choose a reason for hiding this comment

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

AFAICT this isn't an official HTTP spec header right?

No it is not. I tried looking but couldn't find one in an RFC or any widely-used conventions.

what do you think of calling it X-Retry-Attempt

Yeah, I'm changing it to that.

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
@tpaschalis
Copy link
Copy Markdown
Contributor Author

CI is failing due to an unrelated test, could we please restart this check?

Copy link
Copy Markdown
Member

@cstyan cstyan left a comment

Choose a reason for hiding this comment

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

@tpaschalis tests look fine to me?

will merge soon, likely tomorrow

@roidelapluie
Copy link
Copy Markdown
Member

Can we get rid of the X-? I think X- prefix is deprecated in HTTP headers.

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
@tpaschalis
Copy link
Copy Markdown
Contributor Author

Can we get rid of the X-? I think X- prefix is deprecated in HTTP headers.

@roidelapluie yes, done!

@tpaschalis
Copy link
Copy Markdown
Contributor Author

Looks like we hit another test flake here :(
Do you think we're ok to merge this?

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
Copy link
Copy Markdown
Member

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

lgtm

@bboreham bboreham merged commit c173cd5 into prometheus:main Sep 20, 2023
@tpaschalis tpaschalis deleted the add-retry-count-header branch September 20, 2023 10:24
tpaschalis added a commit to grafana/prometheus that referenced this pull request Oct 2, 2023
Header name is `Retry-Attempt`, only set when >0.

Signed-off-by: Marc Tuduri <marctc@protonmail.com>
Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
tpaschalis added a commit to grafana/prometheus that referenced this pull request Oct 3, 2023
Header name is `Retry-Attempt`, only set when >0.

Signed-off-by: Marc Tuduri <marctc@protonmail.com>
Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
tpaschalis added a commit to grafana/prometheus that referenced this pull request Oct 11, 2023
Header name is `Retry-Attempt`, only set when >0.

Signed-off-by: Marc Tuduri <marctc@protonmail.com>
Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
(cherry picked from commit c173cd5)
tpaschalis added a commit to grafana/prometheus that referenced this pull request Oct 16, 2023
Header name is `Retry-Attempt`, only set when >0.

Signed-off-by: Marc Tuduri <marctc@protonmail.com>
Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
(cherry picked from commit c173cd5)
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.

4 participants