55
66from splitio .models .impressions import Impression
77from splitio .models import splits , segments
8- from splitio .models .telemetry import MethodExceptions , MethodLatencies , TelemetryConfig , get_latency_bucket_index
8+ from splitio .models .telemetry import TelemetryConfig , get_latency_bucket_index , TelemetryConfigAsync
99from splitio .storage import SplitStorage , SegmentStorage , ImpressionStorage , EventStorage , \
1010 ImpressionPipelinedStorage , TelemetryStorage
1111from splitio .storage .adapters .redis import RedisAdapterException
@@ -623,7 +623,7 @@ def record_config(self, config, extra_config):
623623 :param congif: factory configuration parameters
624624 :type config: splitio.client.config
625625 """
626- self . _tel_config . record_config ( config , extra_config )
626+ pass
627627
628628 def pop_config_tags (self ):
629629 """Get and reset tags."""
@@ -633,9 +633,8 @@ def push_config_stats(self):
633633 """push config stats to redis."""
634634 pass
635635
636- def _format_config_stats (self , tags ):
636+ def _format_config_stats (self , config_stats , tags ):
637637 """format only selected config stats to json"""
638- config_stats = self ._tel_config .get_stats ()
639638 return json .dumps ({
640639 'aF' : config_stats ['aF' ],
641640 'rF' : config_stats ['rF' ],
@@ -646,7 +645,7 @@ def _format_config_stats(self, tags):
646645
647646 def record_active_and_redundant_factories (self , active_factory_count , redundant_factory_count ):
648647 """Record active and redundant factories."""
649- self . _tel_config . record_active_and_redundant_factories ( active_factory_count , redundant_factory_count )
648+ pass
650649
651650 def add_latency_to_pipe (self , method , bucket , pipe ):
652651 """
@@ -728,8 +727,6 @@ def __init__(self, redis_client, sdk_metadata):
728727 self ._reset_config_tags ()
729728 self ._redis_client = redis_client
730729 self ._sdk_metadata = sdk_metadata
731- self ._method_latencies = MethodLatencies ()
732- self ._method_exceptions = MethodExceptions ()
733730 self ._tel_config = TelemetryConfig ()
734731 self ._make_pipe = redis_client .pipeline
735732
@@ -744,6 +741,15 @@ def add_config_tag(self, tag):
744741 if len (self ._config_tags ) < MAX_TAGS :
745742 self ._config_tags .append (tag )
746743
744+ def record_config (self , config , extra_config ):
745+ """
746+ initilize telemetry objects
747+
748+ :param congif: factory configuration parameters
749+ :type config: splitio.client.config
750+ """
751+ self ._tel_config .record_config (config , extra_config )
752+
747753 def pop_config_tags (self ):
748754 """Get and reset tags."""
749755 with self ._lock :
@@ -754,8 +760,8 @@ def pop_config_tags(self):
754760 def push_config_stats (self ):
755761 """push config stats to redis."""
756762 _LOGGER .debug ("Adding Config stats to redis key %s" % (self ._TELEMETRY_CONFIG_KEY ))
757- _LOGGER .debug (str (self ._format_config_stats (self .pop_config_tags ())))
758- self ._redis_client .hset (self ._TELEMETRY_CONFIG_KEY , self ._sdk_metadata .sdk_version + '/' + self ._sdk_metadata .instance_name + '/' + self ._sdk_metadata .instance_ip , str (self ._format_config_stats (self .pop_config_tags ())))
763+ _LOGGER .debug (str (self ._format_config_stats (self ._tel_config . get_stats (), self . pop_config_tags ())))
764+ self ._redis_client .hset (self ._TELEMETRY_CONFIG_KEY , self ._sdk_metadata .sdk_version + '/' + self ._sdk_metadata .instance_name + '/' + self ._sdk_metadata .instance_ip , str (self ._format_config_stats (self ._tel_config . get_stats (), self . pop_config_tags ())))
759765
760766 def record_active_and_redundant_factories (self , active_factory_count , redundant_factory_count ):
761767 """Record active and redundant factories."""
@@ -777,6 +783,10 @@ def record_exception(self, method):
777783 result = pipe .execute ()
778784 self .expire_keys (self ._TELEMETRY_EXCEPTIONS_KEY , self ._TELEMETRY_KEY_DEFAULT_TTL , 1 , result [0 ])
779785
786+ def record_active_and_redundant_factories (self , active_factory_count , redundant_factory_count ):
787+ """Record active and redundant factories."""
788+ self ._tel_config .record_active_and_redundant_factories (active_factory_count , redundant_factory_count )
789+
780790 def expire_latency_keys (self , total_keys , inserted ):
781791 """
782792 Expire lstency keys
@@ -820,9 +830,7 @@ async def create(redis_client, sdk_metadata):
820830 await self ._reset_config_tags ()
821831 self ._redis_client = redis_client
822832 self ._sdk_metadata = sdk_metadata
823- self ._method_latencies = MethodLatencies () # to be changed to async version class
824- self ._method_exceptions = MethodExceptions () # to be changed to async version class
825- self ._tel_config = TelemetryConfig () # to be changed to async version class
833+ self ._tel_config = await TelemetryConfigAsync .create ()
826834 self ._make_pipe = redis_client .pipeline
827835 return self
828836
@@ -835,6 +843,15 @@ async def add_config_tag(self, tag):
835843 if len (self ._config_tags ) < MAX_TAGS :
836844 self ._config_tags .append (tag )
837845
846+ async def record_config (self , config , extra_config ):
847+ """
848+ initilize telemetry objects
849+
850+ :param congif: factory configuration parameters
851+ :type config: splitio.client.config
852+ """
853+ await self ._tel_config .record_config (config , extra_config )
854+
838855 async def pop_config_tags (self ):
839856 """Get and reset tags."""
840857 tags = self ._config_tags
@@ -844,8 +861,8 @@ async def pop_config_tags(self):
844861 async def push_config_stats (self ):
845862 """push config stats to redis."""
846863 _LOGGER .debug ("Adding Config stats to redis key %s" % (self ._TELEMETRY_CONFIG_KEY ))
847- _LOGGER .debug (str (await self ._format_config_stats (await self .pop_config_tags ())))
848- await self ._redis_client .hset (self ._TELEMETRY_CONFIG_KEY , self ._sdk_metadata .sdk_version + '/' + self ._sdk_metadata .instance_name + '/' + self ._sdk_metadata .instance_ip , str (await self ._format_config_stats (await self .pop_config_tags ())))
864+ _LOGGER .debug (str (await self ._format_config_stats (await self ._tel_config . get_stats (), await self . pop_config_tags ())))
865+ await self ._redis_client .hset (self ._TELEMETRY_CONFIG_KEY , self ._sdk_metadata .sdk_version + '/' + self ._sdk_metadata .instance_name + '/' + self ._sdk_metadata .instance_ip , str (await self ._format_config_stats (await self ._tel_config . get_stats (), await self . pop_config_tags ())))
849866
850867 async def record_exception (self , method ):
851868 """
@@ -863,6 +880,10 @@ async def record_exception(self, method):
863880 result = await pipe .execute ()
864881 await self .expire_keys (self ._TELEMETRY_EXCEPTIONS_KEY , self ._TELEMETRY_KEY_DEFAULT_TTL , 1 , result [0 ])
865882
883+ async def record_active_and_redundant_factories (self , active_factory_count , redundant_factory_count ):
884+ """Record active and redundant factories."""
885+ await self ._tel_config .record_active_and_redundant_factories (active_factory_count , redundant_factory_count )
886+
866887 async def expire_latency_keys (self , total_keys , inserted ):
867888 """
868889 Expire lstency keys
0 commit comments