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

Frontend Refactor #3400

Merged
merged 28 commits into from
Mar 1, 2024
Merged

Frontend Refactor #3400

merged 28 commits into from
Mar 1, 2024

Conversation

joe-elliott
Copy link
Member

@joe-elliott joe-elliott commented Feb 15, 2024

What this PR does:
Refactors the frontend pipeline to accomplish a number of goals detailed below. Currently only the search pipelines have been moved over to the new structure. There will be follow up PRs for other endpoints.

Goals:

  • Provide streaming on all query endpoints
  • Consolidate recombination logic in the frontend/combiner package
  • Consolidate all pipeline building logic in the frontend/pipeline package

See the readme in the pipeline package for details.

Which issue(s) this PR fixes:
Fixes #1392

This PR is progress toward #3366 with an eventual goal to close it.

Changes

  • removes tempo_query_frontend_multitenant... metrics b/c they don't quite fit into the current pattern. this can be improved later.

todo:

  • Flesh out readme.md in /pipeline to describe how to build new pipeline elements

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
@knylander-grafana
Copy link
Contributor

@joe-elliott Was there doc added? I didn't see any in the file list to review.

@joe-elliott
Copy link
Member Author

@joe-elliott Was there doc added? I didn't see any in the file list to review.

There was not. This change is invisible to the user. Unchecking the docs item!

Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
@joe-elliott joe-elliott mentioned this pull request Feb 20, 2024
9 tasks
Signed-off-by: Joe Elliott <number101010@gmail.com>
modules/frontend/pipeline/pipeline.go Outdated Show resolved Hide resolved
modules/frontend/pipeline/async_sharding.go Show resolved Hide resolved
modules/frontend/pipeline/async_sharding.go Outdated Show resolved Hide resolved
modules/frontend/search_handlers.go Show resolved Hide resolved

go func() {
if resps != nil {
asyncResp.Send(resps)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you help me understand more about what resps is? My understanding is that asyncResp.Send(resp) above is the core data flow, sending things up the chain as they come in. This looks like a final send that's already known by the caller?

Copy link
Member Author

@joe-elliott joe-elliott Feb 26, 2024

Choose a reason for hiding this comment

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

this was added to allow the sharder to craft responses unrelated to a request and send them back up the chain. in this case it's used to communicate search job size data up to the combiner.

created here:
https://github.com/grafana/tempo/pull/3400/files#diff-80f55bc33c867c54319fcdfef902b821f96f15e3ec594167bd4c9ab266b7b6eaR120

processed here:
https://github.com/grafana/tempo/pull/3400/files#diff-96cf01ab28f4274fe65e4501fbf82cd479266202d7bc766d3a7c720475568cdaR38-R41

this highlights the largest complication with this PR. code that used to do the recombining was highly context aware:
https://github.com/grafana/tempo/blob/main/modules/frontend/searchsharding.go#L245-L318

b/c it was just executed after all jobs had completed in the same function. Now we are pushing all jobs up to the collector level to stream results. As a result some of that context is lost and it creates "message passing" code like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thanks. Caching is another instance, where the cacheKey is passed through the context.

modules/frontend/pipeline/collector_grpc.go Outdated Show resolved Hide resolved
modules/frontend/combiner/common.go Outdated Show resolved Hide resolved
modules/frontend/frontend.go Show resolved Hide resolved
modules/frontend/frontend.go Outdated Show resolved Hide resolved
modules/frontend/frontend.go Show resolved Hide resolved
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>

go func() {
if resps != nil {
asyncResp.Send(resps)
Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thanks. Caching is another instance, where the cacheKey is passed through the context.

}

// fetch fetches the response body from the cache. the caller assumes the responsibility of closing the response body.
func (c *frontendCache) fetch(key string, pb proto.Message) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method looks unused except for the test, and wasn't sure about json+proto.Message. Since we know it's a proto.Message we could store the binary representation in cache instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

yup. i do think there's an opportunity to make the sync part of the pipeline type aware with generics which would allow this, but we're not quite there yet

Copy link
Contributor

@mdisibio mdisibio left a comment

Choose a reason for hiding this comment

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

I really like this, the async parts seem clearer and streaming everywhere will be awesome. Definitely think we can make the sync parts (cache, etc) also async in the future.

@joe-elliott joe-elliott merged commit c889e63 into grafana:main Mar 1, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Query limits don't work or work unexpectedly
3 participants