Skip to content

Commit a877d95

Browse files
authored
Fix tag propagation of aurora replication_role tag (#17555)
* Set aurora tags on database instance metadata payloads
1 parent 970bbb0 commit a877d95

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

mysql/changelog.d/17555.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix tag propagation of aurora `replication_role` tag. Prior to this change, the replication_role tag was not added as a host tag for mysql aurora instances.

mysql/datadog_checks/mysql/mysql.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,18 @@ def check(self, _):
282282
try:
283283
self._conn = db
284284

285+
# Update tag set with relevant information
286+
if self._get_is_aurora(db):
287+
aurora_tags = self._get_runtime_aurora_tags(db)
288+
self.tags = tags + aurora_tags
289+
self._non_internal_tags = self._set_database_instance_tags(aurora_tags)
290+
285291
# version collection
286292
self.version = get_version(db)
287293
self._send_metadata()
288294
self._send_database_instance_metadata()
289295

290296
self.is_mariadb = self.version.flavor == "MariaDB"
291-
if self._get_is_aurora(db):
292-
tags = tags + self._get_runtime_aurora_tags(db)
293297

294298
self._check_database_configuration(db)
295299

@@ -323,6 +327,13 @@ def check(self, _):
323327
self._conn = None
324328
self._report_warnings()
325329

330+
# _set_database_instance_tags sets the tag list for the `database_instance` resource
331+
# based on metadata that is collected on check start. This ensures that we see tags such as
332+
# `replication_role` appear on the database_instance as a host tag.
333+
def _set_database_instance_tags(self, aurora_tags):
334+
tags = copy.deepcopy(self._non_internal_tags)
335+
return list(set(tags) | set(aurora_tags))
336+
326337
def cancel(self):
327338
self._statement_samples.cancel()
328339
self._statement_metrics.cancel()

0 commit comments

Comments
 (0)