From 9699a432a276ebb83b17f178c0b55cd3873a04a4 Mon Sep 17 00:00:00 2001 From: Bilal Al-Shahwany Date: Mon, 4 Aug 2025 11:30:15 -0700 Subject: [PATCH] Added prevention for telemetry post if counters are empty --- CHANGES.txt | 2 +- splitio/engine/impressions/adapters.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 9bb96d1d..e66834b4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ -10.4.0 (Aug 1, 2025) +10.4.0 (Aug 4, 2025) - Added a new optional argument to the client `getTreatment` methods to allow passing additional evaluation options, such as a map of properties to append to the generated impressions sent to Split backend. Read more in our docs. 10.3.0 (Jun 17, 2025) diff --git a/splitio/engine/impressions/adapters.py b/splitio/engine/impressions/adapters.py index c9d3721f..d5e3dcaf 100644 --- a/splitio/engine/impressions/adapters.py +++ b/splitio/engine/impressions/adapters.py @@ -89,6 +89,9 @@ async def record_unique_keys(self, uniques): :param uniques: unique keys disctionary :type uniques: Dictionary {'feature_flag1': set(), 'feature_flag2': set(), .. } """ + if len(uniques) == 0: + return + await self._telemtry_http_client.record_unique_keys({'keys': self._uniques_formatter(uniques)}) @@ -184,6 +187,9 @@ async def record_unique_keys(self, uniques): :param uniques: unique keys disctionary :type uniques: Dictionary {'feature_flag1': set(), 'feature_flag2': set(), .. } """ + if len(uniques) == 0: + return True + bulk_mtks = _uniques_formatter(uniques) try: inserted = await self._redis_client.rpush(_MTK_QUEUE_KEY, *bulk_mtks) @@ -202,6 +208,9 @@ async def flush_counters(self, to_send): :param to_send: unique keys disctionary :type to_send: Dictionary {'feature_flag1': set(), 'feature_flag2': set(), .. } """ + if len(to_send) == 0: + return True + try: resulted = 0 counted = 0 @@ -277,6 +286,7 @@ def flush_counters(self, to_send): """ if len(to_send) == 0: return + try: resulted = 0 for pf_count in to_send: @@ -325,6 +335,9 @@ async def record_unique_keys(self, uniques): :param uniques: unique keys disctionary :type uniques: Dictionary {'feature_flag1': set(), 'feature_flag2': set(), .. } """ + if len(uniques) == 0: + return True + bulk_mtks = _uniques_formatter(uniques) try: inserted = await self._adapter_client.push_items(self._prefix + _MTK_QUEUE_KEY, *bulk_mtks) @@ -343,6 +356,9 @@ async def flush_counters(self, to_send): :param to_send: unique keys disctionary :type to_send: Dictionary {'feature_flag1': set(), 'feature_flag2': set(), .. } """ + if len(to_send) == 0: + return True + try: resulted = 0 for pf_count in to_send: