fix(analytics): allow capability to offload reportExposure to async thread (SDK-80)#181
Open
tylerjroach wants to merge 3 commits into
Open
fix(analytics): allow capability to offload reportExposure to async thread (SDK-80)#181tylerjroach wants to merge 3 commits into
tylerjroach wants to merge 3 commits into
Conversation
…hread Exposure tracking on the sync path called the user's tracker (and therefore an HTTP POST) inline, blocking every getVariant / getVariantValue / isEnabled call by the full /track round trip. The async paths already use asyncio.create_task; only the sync path was paying the cost. Add an optional `exposure_executor: concurrent.futures.Executor` field to FlagsConfig. When set, the sync providers dispatch the tracker call via executor.submit so flag evaluation returns as soon as the local logic finishes. None (the default) preserves the existing inline behavior. Mirrors mixpanel-java#85. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #181 +/- ##
==========================================
+ Coverage 94.50% 96.02% +1.52%
==========================================
Files 12 13 +1
Lines 1947 3270 +1323
Branches 116 223 +107
==========================================
+ Hits 1840 3140 +1300
- Misses 70 86 +16
- Partials 37 44 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…rage - Add an "Async Exposure Tracking" section to the openfeature-provider README showing how to configure a ThreadPoolExecutor. - Add tests covering the manual track_exposure_event API path (previously only the implicit-via-get_variant path was covered). - Add explicit tests asserting the default (None) still runs inline on the calling thread. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Exposure tracking on the sync path called the user's tracker — and therefore an HTTP POST — inline, blocking every
get_variant/get_variant_value/is_enabledcall by the full/trackround trip. The async paths already useasyncio.create_task; only the sync paths were paying the cost.Add an optional
exposure_executor: concurrent.futures.Executor | None = Nonefield toFlagsConfig(inherited by bothLocalFlagsConfigandRemoteFlagsConfig). When set, the sync providers dispatch the tracker call viaexecutor.submit; flag evaluation returns as soon as the local logic finishes.None(the default) preserves the existing inline behavior — no breaking change for current users.Usage
Context
Linear: SDK-80. Mirrors mixpanel-java#85. Audit-driven; same fix being applied to mixpanel-ruby and mixpanel-go in parallel PRs.
Test plan
exposure_executor=Nonekeeps the old behavior unchanged)thread_name_prefix="exposure") and not the calling thread