From 229a926b55dea15f67a91b5aa42521aceb7eff64 Mon Sep 17 00:00:00 2001 From: Piotr Pauksztelo Date: Thu, 5 Dec 2024 07:38:52 +0100 Subject: [PATCH] Refactor names in generic resolver --- logprep/processor/generic_resolver/processor.py | 12 ++++++------ .../generic_resolver/test_generic_resolver.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/logprep/processor/generic_resolver/processor.py b/logprep/processor/generic_resolver/processor.py index 29dc55d48..2e3449123 100644 --- a/logprep/processor/generic_resolver/processor.py +++ b/logprep/processor/generic_resolver/processor.py @@ -91,9 +91,9 @@ class Metrics(FieldManager.Metrics): ) """Relative cache load.""" - __slots__ = ["_cache_metrics_count"] + __slots__ = ["_cache_metrics_skip_count"] - _cache_metrics_count: int + _cache_metrics_skip_count: int rule_class = GenericResolverRule @@ -173,10 +173,10 @@ def _resolve_value_from_list( def _update_cache_metrics(self): if self.max_cache_entries <= 0: return - self._cache_metrics_count += 1 - if self._cache_metrics_count < self.cache_metrics_interval: + self._cache_metrics_skip_count += 1 + if self._cache_metrics_skip_count < self.cache_metrics_interval: return - self._cache_metrics_count = 0 + self._cache_metrics_skip_count = 0 cache_info = self._get_lru_cached_value_from_list.cache_info() self.metrics.new_results += cache_info.misses @@ -186,4 +186,4 @@ def _update_cache_metrics(self): def setup(self): super().setup() - self._cache_metrics_count = 0 + self._cache_metrics_skip_count = 0 diff --git a/tests/unit/processor/generic_resolver/test_generic_resolver.py b/tests/unit/processor/generic_resolver/test_generic_resolver.py index a439e3662..6fe7acabb 100644 --- a/tests/unit/processor/generic_resolver/test_generic_resolver.py +++ b/tests/unit/processor/generic_resolver/test_generic_resolver.py @@ -582,7 +582,7 @@ def test_resolve_without_cache(self): assert self.object.metrics.cached_results == 0 assert self.object.metrics.num_cache_entries == 0 - def test_resolve_from_cache_with_interval_2_sec(self): + def test_resolve_from_cache_with_update_interval_2(self): config = deepcopy(self.CONFIG) config["cache_metrics_interval"] = 2 config["max_cache_entries"] = 10