Skip to content

Commit 8fcd8fb

Browse files
committed
Add diagnostic events tracker
1 parent 12bf69b commit 8fcd8fb

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

ldclient/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ def __start_up(self, start_wait: float):
284284
log.info("Started LaunchDarkly Client in LDD mode")
285285

286286
diagnostic_accumulator = self._set_event_processor(self._config)
287+
288+
# Pass diagnostic accumulator to data system for streaming metrics
289+
self._data_system.set_diagnostic_accumulator(diagnostic_accumulator)
287290

288291
self.__register_plugins(environment_metadata)
289292

ldclient/impl/datasystem/fdv1.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def __init__(self, config: Config):
7575

7676
# Update processor created in start(), because it needs the ready Event
7777
self._update_processor: Optional[UpdateProcessor] = None
78+
79+
# Diagnostic accumulator provided by client for streaming metrics
80+
self._diagnostic_accumulator = None
7881

7982
# Track current data availability
8083
self._data_availability: DataAvailability = (
@@ -118,6 +121,13 @@ def set_flag_value_eval_fn(self, eval_fn):
118121
(key: str, context: Context) -> Any.
119122
"""
120123
self._flag_tracker_impl = FlagTrackerImpl(self._flag_change_listeners, eval_fn)
124+
125+
def set_diagnostic_accumulator(self, diagnostic_accumulator):
126+
"""
127+
Sets the diagnostic accumulator for streaming initialization metrics.
128+
This should be called before start() to ensure metrics are collected.
129+
"""
130+
self._diagnostic_accumulator = diagnostic_accumulator
121131

122132
@property
123133
def data_source_status_provider(self) -> DataSourceStatusProvider:
@@ -151,8 +161,7 @@ def _make_update_processor(self, config: Config, store: FeatureStore, ready: Eve
151161
return NullUpdateProcessor(config, store, ready)
152162

153163
if config.stream:
154-
# Diagnostic accumulator is handled in client; pass None here
155-
return StreamingUpdateProcessor(config, store, ready, None)
164+
return StreamingUpdateProcessor(config, store, ready, self._diagnostic_accumulator)
156165

157166
# Polling mode
158167
feature_requester = (

0 commit comments

Comments
 (0)