Skip to content

fix: Send AgentToServer.agent_disconnect when client is stopped.#384

Merged
tigrannajaryan merged 5 commits into
open-telemetry:mainfrom
minuk-dev:opamp-agent-disconnect
Aug 12, 2025
Merged

fix: Send AgentToServer.agent_disconnect when client is stopped.#384
tigrannajaryan merged 5 commits into
open-telemetry:mainfrom
minuk-dev:opamp-agent-disconnect

Conversation

@minuk-dev

@minuk-dev minuk-dev commented May 8, 2025

Copy link
Copy Markdown
Contributor

[Edit]
related to #179

[Edit - 2]

  • To ensure to send last scheduled message, when client is stopped.

Comment thread client/internal/clientcommon.go Outdated
@tigrannajaryan

Copy link
Copy Markdown
Member

Sorry for the delay. I suggest that for now we implement agent_disconnect for WebSocket only. If necessary we can add it for http transport later.

@minuk-dev
minuk-dev marked this pull request as draft June 1, 2025 07:29
@minuk-dev
minuk-dev force-pushed the opamp-agent-disconnect branch from 107f2ea to 9c82b12 Compare June 1, 2025 08:02
@minuk-dev
minuk-dev marked this pull request as ready for review June 1, 2025 08:03
@minuk-dev
minuk-dev requested a review from tigrannajaryan June 1, 2025 08:04
@minuk-dev
minuk-dev marked this pull request as draft June 1, 2025 08:17
@minuk-dev
minuk-dev marked this pull request as ready for review June 1, 2025 08:39

@michel-laterman michel-laterman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

Comment thread client/wsclient.go
@agardnerIT

Copy link
Copy Markdown

I believe this logic should be added to HTTP too in order for the collector to be spec-compliant.

@codecov

codecov Bot commented Aug 5, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.19%. Comparing base (3521293) to head (28f76f3).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #384      +/-   ##
==========================================
+ Coverage   80.10%   80.19%   +0.09%     
==========================================
  Files          27       27              
  Lines        2578     2590      +12     
==========================================
+ Hits         2065     2077      +12     
  Misses        395      395              
  Partials      118      118              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tigrannajaryan

Copy link
Copy Markdown
Member

The build is failing because of a bug that will be fixed by #425
Need to wait for that PR to be merged first.

@tigrannajaryan

Copy link
Copy Markdown
Member

@minuk-dev please rebase. The build should now pass.

@minuk-dev
minuk-dev force-pushed the opamp-agent-disconnect branch from 3946fe2 to 28f76f3 Compare August 8, 2025 17:26
@minuk-dev

Copy link
Copy Markdown
Contributor Author

I believe this logic should be added to HTTP too in order for the collector to be spec-compliant.

@agardnerIT I agree with you. But, I think the spec is ambiguous.
But, if we try to send agent_disconnect, we should one more AgentToServer message http.

https://github.com/open-telemetry/opamp-spec/blob/main/specification.md#websocket-transport-opamp-client-initiated

To close a connection the Client MUST first send an AgentToServer message with agent_disconnect field set. The Client MUST then send a WebSocket Close control frame and follow the procedure defined by WebSocket standard.

Should we suggest to add the spec like
"The Client SHOULD send the AgentToServer message with agent_disconnect field set, if the Client is HTTP"?
Honestly, I'm not sure about it. Because sometimes, the http client is hard to send additional message.
So I agree #384 (comment) this review.

Could you please open new issue to discuss it, if you need?
Honestly, this PR is too longly opened... I'm not enough time to do it.

@tigrannajaryan tigrannajaryan left a comment

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.

LGTM. Thank you @minuk-dev

@tigrannajaryan
tigrannajaryan merged commit 89ae916 into open-telemetry:main Aug 12, 2025
11 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.

4 participants