Skip to content

Commit

Permalink
fix typeerror
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeunier28 committed Jul 13, 2023
1 parent 3782b06 commit d4aa0dc
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions postgres/datadog_checks/postgres/statement_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,18 +454,24 @@ def _collect_statement_samples(self):
if self._explain_plan_coll_enabled:
event_samples = self._collect_plans(rows)
for e in event_samples:
self._check.database_monitoring_query_sample(json.dumps(e, default=default_json_event_encoding))
submitted_count += 1
try:
self._check.database_monitoring_query_sample(json.dumps(e, default=default_json_event_encoding))
submitted_count += 1
except TypeError as exe:
self._log.warning("error encoding event to json {}".format(repr(exe)))

if self._report_activity_event():
active_connections = self._get_active_connections()
activity_event = self._create_activity_event(rows, active_connections)
self._check.database_monitoring_query_activity(
json.dumps(activity_event, default=default_json_event_encoding)
)
self._check.histogram(
"dd.postgres.collect_activity_snapshot.time", (time.time() - start_time) * 1000, tags=self.tags
)
try:
self._check.database_monitoring_query_activity(
json.dumps(activity_event, default=default_json_event_encoding)
)
self._check.histogram(
"dd.postgres.collect_activity_snapshot.time", (time.time() - start_time) * 1000, tags=self.tags
)
except TypeError as exe:
self._log.warning("error encoding event to json {}".format(repr(exe)))
elapsed_ms = (time.time() - start_time) * 1000
self._check.histogram(
"dd.postgres.collect_statement_samples.time",
Expand Down

0 comments on commit d4aa0dc

Please sign in to comment.