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: client identification headers #186

Merged
merged 6 commits into from
Feb 5, 2025
Merged

feat: client identification headers #186

merged 6 commits into from
Feb 5, 2025

Conversation

Tymek
Copy link
Member

@Tymek Tymek commented Jan 27, 2025

Identification headers consistent with other Unleash SDKs.

This PR adds standardized client identification headers to the feature and metrics calls that the client makes to Unleash. The headers are:

  • unleash-appname: the name of the application that is using the client. UNLEASH-APPNAME will be deleted in another PR (expand/contract pattern)
  • unleash-connection-id: an internal unique identifier for the current instance of the client generated by the built-in crypto lib
  • unleash-sdk: sdk information in the format unleash-client-<language>:<version>

All the headers are intended for the Unleash team. Changes should be implemented in a way that does not change SDK behavior in a significant way.
The main use cases we have are:

  • capacity planning by knowing the number of unique connections made to the backend API
  • debugging misconfigured SDKs sending more traffic than expected

Fixes issue/1-3271

@Tymek Tymek requested a review from kwasniew January 28, 2025 09:28
@Tymek Tymek marked this pull request as ready for review January 28, 2025 10:52
client.go Outdated Show resolved Hide resolved
@@ -116,3 +116,35 @@ func TestContains(t *testing.T) {
}
})
}

func TestGetConnectionId(t *testing.T) {
for i := 0; i < 100; i++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we run it 100 times? is there something specific about this SDK compared to the others where we test in only once?

Copy link
Member Author

Choose a reason for hiding this comment

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

In order to avoid accidentally passing some tests, because implementation of "make everything random" could accidentally create a version and variant with correct values.

utils.go Show resolved Hide resolved
@Tymek Tymek requested a review from kwasniew February 4, 2025 15:40
utils.go Show resolved Hide resolved
@Tymek Tymek merged commit aab8893 into v4 Feb 5, 2025
19 checks passed
@Tymek Tymek deleted the 1-3271 branch February 5, 2025 09:57
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.

2 participants