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

Enable clients to set flags #286

Merged
merged 5 commits into from
Jun 26, 2024

Conversation

tpaschalis
Copy link
Member

Updates #198

This PR adds a new method to the OpAMPClient that allows clients to set their own flags (such as RequestInstanceUid).

This new method deviates a little bit from other ones as it just sets a uint64 instead of a pointer struct field, and doesn't use the same errors and nil checks.

Thank you in advance for taking and look, and please let me know if I'm missing anything! 🙌

@tpaschalis tpaschalis requested a review from a team June 10, 2024 09:09
Copy link

codecov bot commented Jun 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.32%. Comparing base (c64c461) to head (1f74dfd).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #286      +/-   ##
==========================================
+ Coverage   75.96%   76.32%   +0.35%     
==========================================
  Files          25       25              
  Lines        1656     1681      +25     
==========================================
+ Hits         1258     1283      +25     
  Misses        291      291              
  Partials      107      107              

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

@tpaschalis
Copy link
Member Author

cc @srikanthccv I followed your hint over at #198, let me know if I'm missing anything 🙌

@tigrannajaryan
Copy link
Member

I think this is missing a couple additional things:

  1. Use the Flags from ClientSyncedState in PrepareFirstMessage. This will allow calling SetFlags() before Start() too, which I imagine is useful so that we ask for a new instance id immediately, not after the first request is sent.

  2. Also use the Flags from ClientSyncedState when the server asks ServerToAgentFlags_ServerToAgentFlags_ReportFullState here. This is important since the agent may reconnect to a different server instance after the first sending attempt is done but reply carrying the new instance id was not received.

  3. Once 1 and 2 are added we need to reset the RequestInstanceUid flag after we receive new_instance_uid from the Server, otherwise we will keep asking for new ids every time. Perhaps do it in rcvAgentIdentification after SetInstanceUid returns success.

I may be missing some more things. This needs a bit more thought and additional test cases that demonstrate the real use cases and behavior in presence of failures.

@tpaschalis
Copy link
Member Author

Thanks for the feedback @tigrannajaryan

I focused only on the client-side implementation but I realize it's a more interconnected change. I'll try to set up an end-to-end test to have at hand and figure out the entire lifecycle of the IDs.

@tpaschalis tpaschalis marked this pull request as draft June 10, 2024 15:53
Signed-off-by: Paschalis Tsilias <[email protected]>
… flag after a new ID was requested and set correctly

Signed-off-by: Paschalis Tsilias <[email protected]>
Signed-off-by: Paschalis Tsilias <[email protected]>
@tpaschalis
Copy link
Member Author

Hey there @tigrannajaryan @srikanthccv 👋 Hope your week is going well!

I've pushed a couple of commits; bd001cf that handles the cases Tigran mentioned on your last message and ca66f1d that adds a test for how messages containing valid/invalid AgentIdentification fields interact with the state of the flag we're tracking.

Let me know how this looks, and if you have any concerns, or ideas. I'm still trying to understand all the moving pieces, so if I'm missing anything please let me know!

@tpaschalis tpaschalis marked this pull request as ready for review June 20, 2024 09:05
client/clientimpl_test.go Show resolved Hide resolved
client/internal/clientcommon.go Outdated Show resolved Hide resolved
client/client.go Outdated Show resolved Hide resolved
client/internal/receivedprocessor.go Outdated Show resolved Hide resolved
client/internal/clientstate.go Show resolved Hide resolved
Signed-off-by: Paschalis Tsilias <[email protected]>
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.

LGTM. Just one comment left, would be great to add one more test and we can merge.

client/clientimpl_test.go Show resolved Hide resolved
Signed-off-by: Paschalis Tsilias <[email protected]>
@tigrannajaryan tigrannajaryan merged commit ed38d5f into open-telemetry:main Jun 26, 2024
7 checks passed
@tigrannajaryan
Copy link
Member

Thank you @tpaschalis

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.

2 participants