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

Add streaming remote read to ReadClient #11379

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

leizor
Copy link
Contributor

@leizor leizor commented Sep 30, 2022

Here's another attempt at closing #5926.

I noticed #8351 was stale, and I think this PR has a few improvements over it:

  • I believe the implementation of chunkSeriesIterator.Seek wasn't correct (it allowed for backwards seeking and does not seek past the current chunk).
  • I think I've simplified the implementations of chunkedSeriesSet, chunkedSeries, and chunkedSeriesIterator.
  • The sizeLimit parameter for the ChunkedReader used by the read client is configurable.
  • The read_queries_total and read_request_duration_seconds metrics have an added response_type label that track whether the response from the server was sampled or chunked.
  • The client filters returned samples in the chunked response that are outside of the queried range.

@leizor leizor force-pushed the leizor/streaming-remote-read branch 2 times, most recently from 6349bc9 to 714f69b Compare September 30, 2022 22:14
@leizor leizor marked this pull request as ready for review October 1, 2022 00:39
@leizor leizor force-pushed the leizor/streaming-remote-read branch 7 times, most recently from 5e7735f to 350226f Compare April 24, 2023 16:08
@codesome codesome removed their request for review April 28, 2023 21:41
@roidelapluie
Copy link
Member

cc @bwplotka can you please review this? Thanks

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Looks solid, thanks! 💪🏽

LGTM, just the issue with instrumentation of this. Streaming changes a little bit in semantics of those metrics. Let's ensure those metric remain useful.

storage/remote/client.go Show resolved Hide resolved
storage/remote/client.go Show resolved Hide resolved
storage/remote/codec.go Outdated Show resolved Hide resolved
storage/remote/codec.go Outdated Show resolved Hide resolved
storage/remote/codec.go Outdated Show resolved Hide resolved
storage/remote/codec_test.go Outdated Show resolved Hide resolved
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Last nit, otherwise LGTM, thanks!

@@ -35,12 +35,23 @@ import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"

"github.com/prometheus/prometheus/storage"

Copy link
Member

Choose a reason for hiding this comment

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

blank line not needed

prompb.ReadRequest_STREAMED_XOR_CHUNKS,
prompb.ReadRequest_SAMPLES,
}
)
Copy link
Member

Choose a reason for hiding this comment

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

Let's merge those var sections together?

@@ -66,10 +77,10 @@ var (
Namespace: namespace,
Subsystem: subsystem,
Name: "read_request_duration_seconds",
Help: "Histogram of the latency for remote read requests.",
Help: "Histogram of the latency for remote read requests. Note that for streamed responses this is only the duration of the initial call and does not include the processing of the stream.",
Copy link
Member

Choose a reason for hiding this comment

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

I wished we could actually move this to be full latency including receiving all bytes etc, but good enough for now I guess.

storage/remote/client.go Show resolved Hide resolved
@leizor leizor force-pushed the leizor/streaming-remote-read branch 2 times, most recently from e70669b to 957b07e Compare July 26, 2023 20:02
@leizor
Copy link
Contributor Author

leizor commented Jul 26, 2023

Thanks for all the feedback @bwplotka!

@roidelapluie
Copy link
Member

cc @bwplotka can you look at this PR?

@leizor leizor force-pushed the leizor/streaming-remote-read branch 2 times, most recently from 18a0dac to 6f91a36 Compare October 18, 2023 23:14
@bwplotka
Copy link
Member

Ayay, sorry for delay. Will try to look this/next week. Thanks!

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Nice! Some suggestions + rebase needed, but overall LGTM.

Sorry for lag and thanks for amazing work!

@@ -298,7 +309,11 @@ func (c *Client) Read(ctx context.Context, query *prompb.Query) (*prompb.QueryRe
httpReq.Header.Set("X-Prometheus-Remote-Read-Version", "0.1.0")

ctx, cancel := context.WithTimeout(ctx, c.timeout)
defer cancel()
defer func() {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be cleaner at this point to avoid copying cancel but explictly cancel on errors as needed as you did for status code

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point - will do!

return FromQueryResult(sortSeries, res), nil
}

func (c *Client) handleChunkedResponse(httpResp *http.Response, mint, maxt int64, cancel func(error)) storage.SeriesSet {
Copy link
Member

Choose a reason for hiding this comment

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

Let's inline this method to the caller, too shallow to have it TBH

@leizor leizor force-pushed the leizor/streaming-remote-read branch 4 times, most recently from 6049a11 to 09bca48 Compare January 19, 2024 00:23
@leizor
Copy link
Contributor Author

leizor commented Jan 23, 2024

@bwplotka Thanks for all the feedback, I believe this is now ready to merge!

@beorn7
Copy link
Member

beorn7 commented Mar 26, 2024

@bwplotka did this fall through the cracks? Could you have a look?

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks, and sorry for lag. One non-blocking comment, otherwise LGTM, good to go.

storage/remote/codec.go Show resolved Hide resolved
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

I tried to rebase + resolve conflicts, but it seems it got sideways. Do you mind rebasing that one last time? Sorry!

leizor and others added 6 commits March 28, 2024 10:06
Signed-off-by: Justin Lei <justin.lei@grafana.com>
Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com>
Signed-off-by: Justin Lei <justin.lei@grafana.com>
Signed-off-by: Justin Lei <lei.justin@gmail.com>
Signed-off-by: Justin Lei <lei.justin@gmail.com>
Signed-off-by: Justin Lei <lei.justin@gmail.com>
Signed-off-by: Justin Lei <lei.justin@gmail.com>
@leizor leizor force-pushed the leizor/streaming-remote-read branch 2 times, most recently from dd088cc to 21891f6 Compare March 28, 2024 17:58
@leizor
Copy link
Contributor Author

leizor commented Mar 28, 2024

@bwplotka Yep, not a problem - done!

Signed-off-by: Justin Lei <lei.justin@gmail.com>
Signed-off-by: Justin Lei <lei.justin@gmail.com>
@leizor leizor force-pushed the leizor/streaming-remote-read branch from 870b1d8 to c6dec94 Compare April 26, 2024 17:57
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.

None yet

5 participants