feat: Add environment ID support for hooks - #414
Draft
kinyoklion wants to merge 2 commits into
Draft
Conversation
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
|
@cursor review |
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
This was referenced Aug 13, 2026
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.
Requirements
Related issues
Part of the cross-SDK work to expose the LaunchDarkly environment ID on hook contexts, per the hooks and OTEL specs. Equivalent implementations: launchdarkly/dotnet-core#81, launchdarkly/python-server-sdk#484, launchdarkly/cpp-sdks#594.
Describe the solution you've provided
EvaluationSeriesContextgains an optionalenvironment_id, populated byLDClientfrom the active data system:Both data systems now report it, so the value is only visible once LaunchDarkly has actually answered:
X-LD-EnvIDis read from the streaming connection response headers (SSE::Client#on_connect) and from polling responses (Requestor#request_all_data_with_headers), then recorded on the data sourceUpdateSink, which the FDv1 data system exposes.Basis/Updateby the polling and streaming data sources but discarded; the FDv2 data system now latches it from a successful initializer basis and fromVALIDsynchronizer updates. This also covers the FDv1 fallback synchronizer, which reports headers the same way.Error responses, missing headers, and empty header values are ignored and never clear a previously known ID.
The contract test service reports
environmentIdon the evaluation series context and declares thehook-environment-idcapability.Describe alternatives you've considered
A shared environment-ID holder threaded into each data source was rejected as a side channel; carrying the value with the data/response metadata matches the other SDKs and the existing FDv2
Basis/Updateshape.Additional context
ld-eventsourcechange is needed:SSE::Client#on_connectalready yields the successful response headers on every connection and reconnection.hooks/evaluation/provides the environment IDpasses against the released v2.39.0 harness (default/streaming and polling modes). The repo's v3 contract-test run is pinned tov3.0.0-alpha.6, which predates that test; bumping the pin can be a separateci:change.ruby-server-sdk-otel's tracing hook only uses the configured environment ID today; adding the series-context fallback is a follow-up in that repo.Link to Devin session: https://app.devin.ai/sessions/bfe54128e2804a96bb100e6120e9a3ef
Requested by: @kinyoklion