Skip to content

Commit

Permalink
Expire baseline metrics cache based on size.
Browse files Browse the repository at this point in the history
  • Loading branch information
amw-zero committed May 17, 2024
1 parent 89c9293 commit 2a98e2b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions postgres/datadog_checks/postgres/statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,20 @@ def _check_baseline_metrics_expiry(self):
if (
self._last_baseline_metrics_expiry is None
or self._last_baseline_metrics_expiry + self._config.baseline_metrics_expiry < time.time()
or len(self._baseline_metrics) > 3 * int(self._check.pg_settings.get("pg_stat_statements.max"))
):
self._baseline_metrics = {}
self._query_calls_cache = QueryCallsCache()
self._last_baseline_metrics_expiry = time.time()

self._check.count(
"dd.postgres.statement_metrics.baseline_metrics_cache_reset",
1,
tags=self.tags
+ self._check._get_debug_tags(),
hostname=self._check.resolved_hostname,
)

@tracked_method(agent_check_getter=agent_check_getter, track_result_length=True)
def _collect_metrics_rows(self):
self._emit_pg_stat_statements_metrics()
Expand Down

0 comments on commit 2a98e2b

Please sign in to comment.