Skip to content

Commit

Permalink
Metric
Browse files Browse the repository at this point in the history
  • Loading branch information
sethsamuel committed Dec 24, 2024
1 parent 6c09f70 commit 1cf651f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mysql/datadog_checks/mysql/statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down

0 comments on commit 1cf651f

Please sign in to comment.