@@ -410,7 +410,7 @@ async def block_until_ready(self, timeout=None):
410410 await asyncio .wait_for (asyncio .shield (self ._sdk_ready_flag .wait ()), timeout )
411411 except asyncio .TimeoutError as e :
412412 _LOGGER .error ("Exception initializing SDK" )
413- _LOGGER .error (str (e ))
413+ _LOGGER .debug (str (e ))
414414 await self ._telemetry_init_producer .record_bur_time_out ()
415415 raise TimeoutException ('SDK Initialization: time of %d exceeded' % timeout )
416416
@@ -498,7 +498,8 @@ def _wrap_impression_listener_async(listener, metadata):
498498 return None
499499
500500def _build_in_memory_factory (api_key , cfg , sdk_url = None , events_url = None , # pylint:disable=too-many-arguments,too-many-locals
501- auth_api_base_url = None , streaming_api_base_url = None , telemetry_api_base_url = None ):
501+ auth_api_base_url = None , streaming_api_base_url = None , telemetry_api_base_url = None ,
502+ total_flag_sets = 0 , invalid_flag_sets = 0 ):
502503 """Build and return a split factory tailored to the supplied config."""
503504 if not input_validator .validate_factory_instantiation (api_key ):
504505 return None
@@ -536,7 +537,7 @@ def _build_in_memory_factory(api_key, cfg, sdk_url=None, events_url=None, # pyl
536537 }
537538
538539 storages = {
539- 'splits' : InMemorySplitStorage (),
540+ 'splits' : InMemorySplitStorage (cfg [ 'flagSetsFilter' ] if cfg [ 'flagSetsFilter' ] is not None else [] ),
540541 'segments' : InMemorySegmentStorage (),
541542 'impressions' : InMemoryImpressionStorage (cfg ['impressionsQueueSize' ], telemetry_runtime_producer ),
542543 'events' : InMemoryEventStorage (cfg ['eventsQueueSize' ], telemetry_runtime_producer ),
@@ -607,7 +608,7 @@ def _build_in_memory_factory(api_key, cfg, sdk_url=None, events_url=None, # pyl
607608 unique_keys_tracker = unique_keys_tracker
608609 )
609610
610- telemetry_init_producer .record_config (cfg , extra_cfg )
611+ telemetry_init_producer .record_config (cfg , extra_cfg , total_flag_sets , invalid_flag_sets )
611612
612613 if preforked_initialization :
613614 synchronizer .sync_all (max_retry_attempts = _MAX_RETRY_SYNC_ALL )
@@ -625,7 +626,8 @@ def _build_in_memory_factory(api_key, cfg, sdk_url=None, events_url=None, # pyl
625626 telemetry_submitter )
626627
627628async def _build_in_memory_factory_async (api_key , cfg , sdk_url = None , events_url = None , # pylint:disable=too-many-arguments,too-many-localsa
628- auth_api_base_url = None , streaming_api_base_url = None , telemetry_api_base_url = None ):
629+ auth_api_base_url = None , streaming_api_base_url = None , telemetry_api_base_url = None ,
630+ total_flag_sets = 0 , invalid_flag_sets = 0 ):
629631 """Build and return a split factory tailored to the supplied config in async mode."""
630632 if not input_validator .validate_factory_instantiation (api_key ):
631633 return None
@@ -663,7 +665,7 @@ async def _build_in_memory_factory_async(api_key, cfg, sdk_url=None, events_url=
663665 }
664666
665667 storages = {
666- 'splits' : InMemorySplitStorageAsync (),
668+ 'splits' : InMemorySplitStorageAsync (cfg [ 'flagSetsFilter' ] if cfg [ 'flagSetsFilter' ] is not None else [] ),
667669 'segments' : InMemorySegmentStorageAsync (),
668670 'impressions' : InMemoryImpressionStorageAsync (cfg ['impressionsQueueSize' ], telemetry_runtime_producer ),
669671 'events' : InMemoryEventStorageAsync (cfg ['eventsQueueSize' ], telemetry_runtime_producer ),
@@ -733,7 +735,7 @@ async def _build_in_memory_factory_async(api_key, cfg, sdk_url=None, events_url=
733735 unique_keys_tracker = unique_keys_tracker
734736 )
735737
736- await telemetry_init_producer .record_config (cfg , extra_cfg )
738+ await telemetry_init_producer .record_config (cfg , extra_cfg , total_flag_sets , invalid_flag_sets )
737739
738740 if preforked_initialization :
739741 await synchronizer .sync_all (max_retry_attempts = _MAX_RETRY_SYNC_ALL )
@@ -814,7 +816,7 @@ def _build_redis_factory(api_key, cfg):
814816 initialization_thread = threading .Thread (target = manager .start , name = "SDKInitializer" , daemon = True )
815817 initialization_thread .start ()
816818
817- telemetry_init_producer .record_config (cfg , {})
819+ telemetry_init_producer .record_config (cfg , {}, 0 , 0 )
818820
819821 split_factory = SplitFactory (
820822 api_key ,
@@ -894,7 +896,7 @@ async def _build_redis_factory_async(api_key, cfg):
894896 )
895897
896898 manager = RedisManagerAsync (synchronizer )
897- await telemetry_init_producer .record_config (cfg , {})
899+ await telemetry_init_producer .record_config (cfg , {}, 0 , 0 )
898900 manager .start ()
899901
900902 split_factory = SplitFactoryAsync (
@@ -977,7 +979,7 @@ def _build_pluggable_factory(api_key, cfg):
977979 initialization_thread = threading .Thread (target = manager .start , name = "SDKInitializer" , daemon = True )
978980 initialization_thread .start ()
979981
980- telemetry_init_producer .record_config (cfg , {})
982+ telemetry_init_producer .record_config (cfg , {}, 0 , 0 )
981983
982984 split_factory = SplitFactory (
983985 api_key ,
@@ -1056,7 +1058,7 @@ async def _build_pluggable_factory_async(api_key, cfg):
10561058 # Using same class as redis for consumer mode only
10571059 manager = RedisManagerAsync (synchronizer )
10581060 manager .start ()
1059- await telemetry_init_producer .record_config (cfg , {})
1061+ await telemetry_init_producer .record_config (cfg , {}, 0 , 0 )
10601062
10611063 split_factory = SplitFactoryAsync (
10621064 api_key ,
@@ -1083,7 +1085,7 @@ def _build_localhost_factory(cfg):
10831085 telemetry_evaluation_producer = telemetry_producer .get_telemetry_evaluation_producer ()
10841086
10851087 storages = {
1086- 'splits' : InMemorySplitStorage (),
1088+ 'splits' : InMemorySplitStorage (cfg [ 'flagSetsFilter' ] if cfg [ 'flagSetsFilter' ] is not None else [] ),
10871089 'segments' : InMemorySegmentStorage (), # not used, just to avoid possible future errors.
10881090 'impressions' : LocalhostImpressionsStorage (),
10891091 'events' : LocalhostEventsStorage (),
@@ -1238,7 +1240,10 @@ def get_factory(api_key, **kwargs):
12381240 _INSTANTIATED_FACTORIES .update ([api_key ])
12391241 _INSTANTIATED_FACTORIES_LOCK .release ()
12401242
1241- config = sanitize_config (api_key , kwargs .get ('config' , {}))
1243+ config_raw = kwargs .get ('config' , {})
1244+ total_flag_sets , invalid_flag_sets = _get_total_and_invalid_flag_sets (config_raw )
1245+
1246+ config = sanitize_config (api_key , config_raw )
12421247
12431248 if config ['operationMode' ] == 'localhost' :
12441249 split_factory = _build_localhost_factory (config )
@@ -1254,7 +1259,9 @@ def get_factory(api_key, **kwargs):
12541259 kwargs .get ('events_api_base_url' ),
12551260 kwargs .get ('auth_api_base_url' ),
12561261 kwargs .get ('streaming_api_base_url' ),
1257- kwargs .get ('telemetry_api_base_url' ))
1262+ kwargs .get ('telemetry_api_base_url' ),
1263+ total_flag_sets ,
1264+ invalid_flag_sets )
12581265
12591266 return split_factory
12601267
@@ -1282,8 +1289,10 @@ async def get_factory_async(api_key, **kwargs):
12821289 _INSTANTIATED_FACTORIES .update ([api_key ])
12831290 _INSTANTIATED_FACTORIES_LOCK .release ()
12841291
1285- config = sanitize_config (api_key , kwargs .get ('config' , {}))
1292+ config_raw = kwargs .get ('config' , {})
1293+ total_flag_sets , invalid_flag_sets = _get_total_and_invalid_flag_sets (config_raw )
12861294
1295+ config = sanitize_config (api_key , config_raw )
12871296 if config ['operationMode' ] == 'localhost' :
12881297 split_factory = await _build_localhost_factory_async (config )
12891298 elif config ['storageType' ] == 'redis' :
@@ -1298,8 +1307,9 @@ async def get_factory_async(api_key, **kwargs):
12981307 kwargs .get ('events_api_base_url' ),
12991308 kwargs .get ('auth_api_base_url' ),
13001309 kwargs .get ('streaming_api_base_url' ),
1301- kwargs .get ('telemetry_api_base_url' ))
1302-
1310+ kwargs .get ('telemetry_api_base_url' ),
1311+ total_flag_sets ,
1312+ invalid_flag_sets )
13031313 return split_factory
13041314
13051315def _get_active_and_redundant_count ():
@@ -1310,4 +1320,13 @@ def _get_active_and_redundant_count():
13101320 redundant_factory_count += _INSTANTIATED_FACTORIES [item ] - 1
13111321 active_factory_count += _INSTANTIATED_FACTORIES [item ]
13121322 _INSTANTIATED_FACTORIES_LOCK .release ()
1313- return redundant_factory_count , active_factory_count
1323+ return redundant_factory_count , active_factory_count
1324+
1325+ def _get_total_and_invalid_flag_sets (config_raw ):
1326+ total_flag_sets = 0
1327+ invalid_flag_sets = 0
1328+ if config_raw .get ('flagSetsFilter' ) is not None and isinstance (config_raw .get ('flagSetsFilter' ), list ):
1329+ total_flag_sets = len (config_raw .get ('flagSetsFilter' ))
1330+ invalid_flag_sets = total_flag_sets - len (input_validator .validate_flag_sets (config_raw .get ('flagSetsFilter' ), 'Telemetry Init' ))
1331+
1332+ return total_flag_sets , invalid_flag_sets
0 commit comments