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

feat: websocket: support no response. #355

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tttoad
Copy link
Contributor

@tttoad tttoad commented Feb 25, 2025

Resolves #346

https://opentelemetry.io/docs/specs/opamp/#websocket-message-exchange
The specification does not require that we must respond to client messages in WebSocket, and we should support not responding to messages. This will reduce sending empty responses.

@tttoad tttoad requested a review from a team as a code owner February 25, 2025 05:49
Copy link

codecov bot commented Feb 25, 2025

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.45%. Comparing base (e718373) to head (0d741ce).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
server/serverimpl.go 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #355      +/-   ##
==========================================
- Coverage   78.50%   78.45%   -0.05%     
==========================================
  Files          25       25              
  Lines        2405     2423      +18     
==========================================
+ Hits         1888     1901      +13     
- Misses        410      414       +4     
- Partials      107      108       +1     

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

Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

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

We also need to handle the case OnMessage() returning nil in handlePlainHTTPRequest. However, there we MUST send a response (because plain HTTP), so if nil, we must substitute it by empty message. And add a test for plain http too - ideally use one test iterating over both transports.

@@ -264,6 +264,10 @@ func (s *server) handleWSConnection(reqCtx context.Context, wsConn *websocket.Co
}

response := connectionCallbacks.OnMessage(msgContext, agentConn, &request)
Copy link
Member

Choose a reason for hiding this comment

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

Please also update doc-comment for OnMessage. It currently says "Must return a ServerToAgent message...".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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.

[Feat]: websocket support does not return messages.
2 participants