Skip to content

Commit

Permalink
Adds additional debug logging to help with schema collection investig…
Browse files Browse the repository at this point in the history
…ations (#18754)
  • Loading branch information
aldrickdev authored Oct 3, 2024
1 parent b6cbfdb commit bdd7dc8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions postgres/changelog.d/18754.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adds additional debug logging to help with schema collection investigations
17 changes: 17 additions & 0 deletions postgres/datadog_checks/postgres/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ def report_postgres_metadata(self):
continue

tables = self._query_tables_for_schema(cursor, schema["id"], dbname)
self._log.debug(
"Tables found for schema '{schema}' in database '{database}':"
"{tables}".format(
schema=database["schemas"],
database=dbname,
tables=[table["name"] for table in tables],
)
)
table_chunks = list(get_list_chunks(tables, chunk_size))

buffer_column_count = 0
Expand Down Expand Up @@ -415,6 +423,8 @@ def _query_schema_information(self, cursor: psycopg2.extensions.cursor, dbname:
schemas = []
for row in rows:
schemas.append({"id": str(row["id"]), "name": row["name"], "owner": row["owner"]})

self._log.debug("Schemas found for database '{database}': [{schemas}]".format(database=dbname, schemas=rows))
return schemas

def _get_table_info(self, cursor, dbname, schema_id):
Expand All @@ -437,6 +447,13 @@ def _get_table_info(self, cursor, dbname, schema_id):
if len(table_info) <= limit:
return table_info

self._log.debug(
"{table_count} tables found but max_tables is set to {max_tables}."
"{missing_count} tables will be missing from this collection".format(
table_count=len(table_info), max_tables=limit, missing_count=len(table_info) - limit
)
)

if not self._config.relations:
self._check.log.warning(
"Number of tables exceeds limit of %d set by max_tables but "
Expand Down

0 comments on commit bdd7dc8

Please sign in to comment.