feat: add X-LaunchDarkly-Instance-Id header to server SDK (SDK-2353)#532
Merged
Conversation
Generate a v4 UUID once per SDK instance in ClientImpl's constructor and stamp it on the shared HttpProperties. Because the same HttpProperties is threaded through the data system (streaming and polling) and event processor, every outbound request carries the same stable per-instance identifier without per-channel plumbing. The new instance_id helper wraps boost::uuids::random_generator (already a transitive Boost dependency of the SDK), so no new third-party packages are introduced. Registers the "instance-id" capability with the server contract test service so the cross-SDK harness can verify the header on stream, poll, and event requests.
kinyoklion
reviewed
May 28, 2026
Comment on lines
+10
to
+14
| // boost::uuids::random_generator emits a version 4 (random) UUID, which is | ||
| // what the SCMP spec requires. The generator carries state (an internal | ||
| // RNG), so constructing it on every call is fine for our use case where we | ||
| // only call MakeInstanceId once per SDK instance. | ||
| static thread_local boost::uuids::random_generator generator; |
Member
There was a problem hiding this comment.
Suggested change
| // boost::uuids::random_generator emits a version 4 (random) UUID, which is | |
| // what the SCMP spec requires. The generator carries state (an internal | |
| // RNG), so constructing it on every call is fine for our use case where we | |
| // only call MakeInstanceId once per SDK instance. | |
| static thread_local boost::uuids::random_generator generator; | |
| // boost::uuids::random_generator emits a version 4 (random) UUID, which is | |
| // what the SCMP spec requires. The generator carries state (an internal RNG | |
| // seeded from system entropy on construction), so we cache it per thread to | |
| // avoid redundant entropy draws on repeated calls. | |
| static thread_local boost::uuids::random_generator generator; |
Member
Author
There was a problem hiding this comment.
Done -- updated the comment to your wording in 9ecdc7e.
kinyoklion
reviewed
May 28, 2026
| * that is generated once per SDK instance and remains constant for the | ||
| * lifetime of the client. | ||
| * | ||
| * See: sdk-specs / SCMP-server-connection-minutes-polling. |
Member
There was a problem hiding this comment.
Suggested change
| * See: sdk-specs / SCMP-server-connection-minutes-polling. |
Member
Author
There was a problem hiding this comment.
Done -- removed the spec reference line in 9ecdc7e.
kinyoklion
approved these changes
May 28, 2026
Member
kinyoklion
left a comment
There was a problem hiding this comment.
Approved pending comment changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
X-LaunchDarkly-Instance-Idheader to every outbound polling, streaming, and event request fromlibs/server-sdk. Value is a v4 UUID (viaboost::uuids::random_generator, the same generator already used byasio_event_processorforX-LaunchDarkly-Payload-Id) generated once per SDK instance and stable for that instance's lifetime.The UUID is generated in
ClientImpl's constructor and stamped onto base headers alongsideuser-agent,authorization, andx-launchdarkly-tags.Design note (worth a reviewer's attention)
The UUID is generated in
ClientImplctor rather than inHttpPropertiesBuilder::Build()becauseBuild()is called twice on the same logical SDK instance (once duringConfigBuilder::Build, again duringClientImplconstruction when authorization/user-agent are layered on). Generating inBuild()would produce two different UUIDs per SDK instance, violating the "constant throughout the lifetime" requirement.Scope
libs/server-sdkonly. The sharedHttpPropertiesBuilderinlibs/commonis untouched; the analog work forlibs/client-sdkis intentionally out of scope.Test plan
libs/server-sdk/tests/instance_id_test.cpp: UUID v4 format check (regex on4xxx/[89ab]xxxvariant bits), 100-sample uniqueness, header-name constant, client construction smoke test"instance-id"capability incontract-tests/server-contract-tests/src/main.cppNote
Low Risk
Scoped wire-contract header in server-sdk only; generation is isolated and covered by unit and contract tests, with no auth or data-path changes.
Overview
Adds
X-LaunchDarkly-Instance-Idon outbound server SDK HTTP traffic (polling, streaming, and events) so SCMP server-connection-minutes can attribute requests to a single SDK process.A new
MakeInstanceId()helper produces a v4 UUID (Boostrandom_generator, thread-local). The value is set once whenClientImplbuilds sharedHttpProperties—not insideHttpPropertiesBuilder::Build(), because config and client each callBuild()and a second UUID would break the “stable for this instance” rule.libs/commonand client-sdk are unchanged. Contract tests advertise capabilityinstance-id;instance_id_test.cppcovers format, uniqueness, header name, and client construction.Reviewed by Cursor Bugbot for commit 9ecdc7e. Bugbot is set up for automated code reviews on this repo. Configure here.