Skip to content

Commit

Permalink
fixes issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dalextorres committed Aug 28, 2024
1 parent 4281d4d commit c9ee6d9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
1 change: 1 addition & 0 deletions mysql/changelog.d/18450.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handles mysql azure flexible server warning bug
30 changes: 15 additions & 15 deletions mysql/datadog_checks/mysql/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,21 @@ def run_job(self):
self._log.debug(
'Waiting for events_waits_current availability to be determined by the check, skipping run.'
)
# Azure flexible server
azure_deployment_type = self._config.cloud_metadata.get("azure", {}).get("deployment_type")
if self._check.events_wait_current_enabled is False and azure_deployment_type != 'flexible_server':
self._check.record_warning(
DatabaseConfigurationError.events_waits_current_not_enabled,
warning_with_tags(
'Query activity and wait event collection is disabled on this host. To enable it, the setup '
'consumer `performance-schema-consumer-events-waits-current` must be enabled on the MySQL server. '
'Please refer to the troubleshooting documentation: '
'https://docs.datadoghq.com/database_monitoring/setup_mysql/troubleshooting#%s',
DatabaseConfigurationError.events_waits_current_not_enabled.value,
code=DatabaseConfigurationError.events_waits_current_not_enabled.value,
host=self._check.resolved_hostname,
),
)
if self._check.events_wait_current_enabled is False:
azure_deployment_type = self._config.cloud_metadata.get("azure", {}).get("deployment_type")
if azure_deployment_type != "flexible_server":
self._check.record_warning(
DatabaseConfigurationError.events_waits_current_not_enabled,
warning_with_tags(
'Query activity and wait event collection is disabled on this host. To enable it, the setup '
'consumer `performance-schema-consumer-events-waits-current` must be enabled on the MySQL server. '
'Please refer to the troubleshooting documentation: '
'https://docs.datadoghq.com/database_monitoring/setup_mysql/troubleshooting#%s',
DatabaseConfigurationError.events_waits_current_not_enabled.value,
code=DatabaseConfigurationError.events_waits_current_not_enabled.value,
host=self._check.resolved_hostname,
),
)
return
self._check_version()
self._collect_activity()
Expand Down
20 changes: 11 additions & 9 deletions mysql/tests/test_query_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,28 +476,30 @@ def test_events_wait_current_disabled(dbm_instance, dd_run_check, root_conn, agg
assert check.warnings == []
assert dbm_activity, "should have collected at least one activity"


@pytest.mark.integration
@pytest.mark.usefixtures('dd_environment')
@pytest.mark.parametrize(
"cloud_metadata",
[
(
{
'azure': {
'deployment_type': 'flexible_server',
'name': 'my-instance',
},
{
'azure': {
'deployment_type': 'flexible_server',
'name': 'my-instance',
},
),
]
},
],
)
def test_events_wait_current_disabled_no_warning_azure_flexible_server(dbm_instance, dd_run_check, root_conn, aggregator, cloud_metadata):
def test_events_wait_current_disabled_no_warning_azure_flexible_server(
dbm_instance, dd_run_check, root_conn, aggregator, cloud_metadata
):
'''
This test verifies that the check will not emit a warning if the events_waits_current is disabled and Azure deployment_type is flexible_server.
'''
if cloud_metadata:
for k, v in cloud_metadata.items():
dbm_instance[k] = v
dbm_instance['options']['extra_performance_metrics'] = False
check = MySql(CHECK_NAME, {}, [dbm_instance])

# disable events_waits_current, expect events_wait_current_enabled to be set to False
Expand Down

0 comments on commit c9ee6d9

Please sign in to comment.