feat: add X-LaunchDarkly-Instance-Id header (SDK-2355)#111
Open
keelerm84 wants to merge 3 commits into
Open
Conversation
Generate a v4 UUID once per SDK instance in the HTTP configuration builder and stamp it on defaultRequestHeaders. Because that header list is shared by the polling, streaming, and event clients, every outbound request carries the same stable per-instance identifier without per-channel plumbing. The builder lives in a new internal module LaunchDarkly.Server.Config.HttpConfigurationInternal so it can pull from Config.Internal without creating an import cycle through Config.ClientContext / DataSource.Internal. The instance-id header name and a thin makeInstanceIdHeader helper stay in LaunchDarkly.Server.Config.HttpConfiguration so unit tests can exercise the GUID generation directly. Registers the "instance-id" capability with the contract-test service so the cross-SDK harness can verify the header on stream, poll, and event requests.
Replace `x /= Nothing` with `isJust x` in two assertions in Spec.HttpConfiguration, per hlint's "Use isJust" suggestion. The quality-checks CI job runs hlint with `fail-on: warning` and was failing on these two warnings.
…K-2355) Moves makeHttpConfiguration into Client.Internal alongside clientVersion, removing the Config/HttpConfigurationInternal module that existed only to work around an import cycle. The instance-id header is generated inline in makeHttpConfiguration rather than via a separate makeInstanceIdHeader helper, so Config.HttpConfiguration is back to just the HttpConfiguration type and prepareRequest.
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. Value is a v4 UUID generated once per SDK instance (viaData.UUID.V4.nextRandom) and stamped intodefaultRequestHeadersso it rides every channel through the existing HTTP-configuration layer.Design note: module-cycle workaround
makeHttpConfigurationcould not live insideHttpConfiguration.hsbecauseConfig.Internaltransitively reaches back toHttpConfigurationviaDataSource.Internal -> Config.ClientContext. A new internal moduleLaunchDarkly.Server.Config.HttpConfigurationInternalhouses the function.clientVersionis passed in as a function argument fromClient.hsrather than imported, to keep the cycle from re-forming. This is Haskell-specific scaffolding the other SDKs didn't need.Test plan
stack test— 184 / 184 HUnit cases pass (178 baseline + 6 new)fourmolu --mode checkonsrc/andtest/— clean"instance-id"capability registeredsdk-test-harnessinstance available in this sandbox. CI will exercise the harness.Note
Medium Risk
Adds a new automatically generated header to every polling/streaming/event HTTP request, which can affect network behavior and downstream logging/metrics. Low code volume, but touches shared HTTP configuration used across all request paths.
Overview
Adds automatic inclusion of
X-LaunchDarkly-Instance-Idon all outbound SDK HTTP traffic by generating a UUIDv4 once permakeHttpConfigurationcall and stamping it intodefaultRequestHeaders.Refactors
makeHttpConfigurationintoLaunchDarkly.Server.Client.Internal(and updates imports/call sites) so the shared HTTP configuration layer carries this identifier across polling, streaming, and event clients.Updates contract-test capabilities to advertise
instance-id, and adds a new HUnit spec (Spec.HttpConfiguration) to validate header presence, uniqueness, UUIDv4 format, and per-instance variability.Reviewed by Cursor Bugbot for commit 28900f8. Bugbot is set up for automated code reviews on this repo. Configure here.