Skip to content

Commit

Permalink
Refactor names in generic resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
ppcad committed Dec 5, 2024
1 parent 9ae87ea commit 229a926
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions logprep/processor/generic_resolver/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 229a926

Please sign in to comment.