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

Websocket support for search streaming #2971

Merged
merged 26 commits into from
Oct 6, 2023

Conversation

joe-elliott
Copy link
Member

@joe-elliott joe-elliott commented Sep 29, 2023

What this PR does:
Adds websocket support for streaming and deprecates the GRPC endpoint. Due to the issues we've seen with sharing GRPC and HTTP on the same port (which Grafana requires) we believe this is a better path for streaming data. The way this is currently implemented Tempo will close the websocket after it has completed the query and ignore all messages from the client except for normal closure (1000).

Other changes:

  • Fixes a bug where spss is not respected on the GRPC endpoint
  • Extended the tempo search cli to support normal http, streaming websockets and streaming grpc

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

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>
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>
Copy link
Contributor

@knylander-grafana knylander-grafana left a comment

Choose a reason for hiding this comment

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

Approving doc changes. Thank you for adding docs.

joe-elliott and others added 3 commits October 2, 2023 09:26
Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com>
Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com>
Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com>
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.

Looking pretty gtm. Still reviewing and hope to test it out locally.

modules/frontend/search_streaming.go Show resolved Hide resolved
modules/frontend/search_streaming.go Show resolved Hide resolved
Signed-off-by: Joe Elliott <number101010@gmail.com>
Copy link
Member

@electron0zero electron0zero left a comment

Choose a reason for hiding this comment

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

lgtm.

ps: I didn't test it localy, I am trusting @mdisibio to do it :)

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

mdisibio commented Oct 5, 2023

Testing this locally and looking great. However noticed a small issue with the closure error handling.

Debugging shows that Tempo is finishing the query successfully and closing the connection from the server-side on line 210 However then the deferred reader to detect unexpected client closure is tripping. Instead of getting websocket.CloseNormalClosure it's getting a net.OpError wrapping a poll.errNetClosing. The end result is it logs the error each time. Not noticing any other impact.
image

Reproduced with both:

  • ./tempo-cli query api search "localhost:3200" "{duration>1s}" 2023-10-03T00:00:00Z 2023-10-06T00:00:00Z --limit=10000 --use-ws
  • curl -v "ws://localhost:3200/api/search-ws?start=1696305600&end=1696564800&limit=100000&q=%7Bduration%3E1s%7D"

Signed-off-by: Joe Elliott <number101010@gmail.com>
@joe-elliott
Copy link
Member Author

Testing this locally and looking great. However noticed a small issue with the closure error handling.

Good catch. Not sure how I missed this. I feel like the cleanest solution is just to store a bool on the server side that records whether or not we've attempted a closure on the connection. I don't think the error produced can be tested directly to determine if it was graceful or unexpected: 2d4206c

Signed-off-by: Joe Elliott <number101010@gmail.com>
@joe-elliott joe-elliott merged commit 7e0cb51 into grafana:main Oct 6, 2023
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
None yet
Development

Successfully merging this pull request may close these issues.

Add websocket support for TraceQL streaming
4 participants