From 1cf651f3671454d40767c8718821b6142ee6ea3e Mon Sep 17 00:00:00 2001 From: Seth Samuel Date: Tue, 24 Dec 2024 12:52:05 -0500 Subject: [PATCH] Metric --- mysql/datadog_checks/mysql/statements.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mysql/datadog_checks/mysql/statements.py b/mysql/datadog_checks/mysql/statements.py index 551876945e36c..c8a49e18c71f8 100644 --- a/mysql/datadog_checks/mysql/statements.py +++ b/mysql/datadog_checks/mysql/statements.py @@ -116,7 +116,15 @@ def _close_db_conn(self): self._db = None def run_job(self): + start = time() self.collect_per_statement_metrics() + self._check.gauge( + "dd.mysql.statement_metrics.elapsed_ms", + time() - start, + tags=self._check.tags + self._check._get_debug_tags(), + hostname=self._check.resolved_hostname, + ) + @tracked_method(agent_check_getter=attrgetter('_check')) def collect_per_statement_metrics(self): @@ -162,7 +170,7 @@ def collect_per_statement_metrics(self): 'mysql_rows': rows, } self._check.database_monitoring_query_metrics(json.dumps(payload, default=default_json_event_encoding)) - self._check.count( + self._check.gauge( "dd.mysql.collect_per_statement_metrics.rows", len(rows), tags=tags + self._check._get_debug_tags(), @@ -172,7 +180,7 @@ def collect_per_statement_metrics(self): def _collect_per_statement_metrics(self, tags): # type: () -> List[PyMysqlRow] monotonic_rows = self._query_summary_per_statement() - self._check.count( + self._check.gauge( "dd.mysql.statement_metrics.rows", len(monotonic_rows), tags=tags + self._check._get_debug_tags(),