Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mysql/changelog.d/21198.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Properly cleanup schema metadata memory references after all collection cycles
36 changes: 20 additions & 16 deletions mysql/datadog_checks/mysql/databases_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def reset(self):
self._total_columns_sent = 0
self._columns_count = 0
self.db_info.clear()
self.db_to_tables.clear()
self.any_tables_found = False

def store_db_infos(self, db_infos):
Expand Down Expand Up @@ -183,7 +184,7 @@ def _fetch_database_data(self, cursor, start_time, db_name):
self._data_submitter.submit()

@tracked_method(agent_check_getter=agent_check_getter)
def _collect_databases_data(self, tags):
def collect_databases_data(self, tags):
"""
Collects database information and schemas and submits them to the agent's queue as dictionaries.

Expand Down Expand Up @@ -247,22 +248,25 @@ def _collect_databases_data(self, tags):
- data_length (int): The data length of the partition in bytes. If partition has
subpartitions, this is the sum of all subpartitions data_length.
"""
self._data_submitter.reset()
self._data_submitter.reset() # Ensure we start fresh
self._tags = tags
with closing(self._metadata.get_db_connection().cursor(CommenterDictCursor)) as cursor:
self._data_submitter.set_base_event_data(
self._check.reported_hostname,
self._check.database_identifier,
self._tags,
self._check._config.cloud_metadata,
self._check.version.version,
self._check.version.flavor,
)
db_infos = self._query_db_information(cursor)
self._data_submitter.store_db_infos(db_infos)
self._fetch_for_databases(db_infos, cursor)
self._data_submitter.submit()
self._log.debug("Finished collect_schemas_data")
self._data_submitter.set_base_event_data(
self._check.reported_hostname,
self._check.database_identifier,
self._tags,
self._check._config.cloud_metadata,
self._check.version.version,
self._check.version.flavor,
)
try:
with closing(self._metadata.get_db_connection().cursor(CommenterDictCursor)) as cursor:
db_infos = self._query_db_information(cursor)
self._data_submitter.store_db_infos(db_infos)
self._fetch_for_databases(db_infos, cursor)
self._data_submitter.submit()
finally:
self._data_submitter.reset() # Ensure we reset in case of errors
self._log.debug("Finished collect_databases_data")

def _fetch_for_databases(self, db_infos, cursor):
start_time = time.time()
Expand Down
2 changes: 1 addition & 1 deletion mysql/datadog_checks/mysql/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def run_job(self):
if self._databases_data_enabled and elapsed_time_databases >= self._databases_data_collection_interval:
self._last_databases_collection_time = time.time()
try:
self._databases_data._collect_databases_data(self._tags)
self._databases_data.collect_databases_data(self._tags)
except Exception as e:
self._log.error(
"""An error occurred while collecting schema data.
Expand Down
7 changes: 7 additions & 0 deletions openai/assets/dataflows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
provides:
- id: openai-usage-metrics
always_on: true
- id: openai-cloud-cost-data
always_on: false
- id: openai-llm-completions
always_on: false
Loading