Skip to content

Commit

Permalink
support previous key
Browse files Browse the repository at this point in the history
  • Loading branch information
djova committed Jul 9, 2021
1 parent 2d0e118 commit c0d3592
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mysql/datadog_checks/mysql/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, instance):
self.full_statement_text_samples_per_hour_per_query = instance.get(
'full_statement_text_samples_per_hour_per_query', 1
)
self.statement_samples_config = instance.get('query_samples', {}) or {}
self.statement_samples_config = instance.get('query_samples', instance.get('statement_samples', {})) or {}
self.statement_metrics_config = instance.get('query_metrics', {}) or {}
self.min_collection_interval = instance.get('min_collection_interval', 15)
self.configuration_checks()
Expand Down
14 changes: 14 additions & 0 deletions mysql/tests/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ def test_dbm_enabled_config(dbm_instance, dbm_enabled_key, dbm_enabled):
assert mysql_check._config.dbm_enabled == dbm_enabled


statement_samples_keys = ["query_samples", "statement_samples"]


@pytest.mark.parametrize("statement_samples_key", statement_samples_keys)
@pytest.mark.parametrize("statement_samples_enabled", [True, False])
def test_statement_samples_enabled_config(dbm_instance, statement_samples_key, statement_samples_enabled):
# test to make sure we continue to support the old key
for k in statement_samples_keys:
dbm_instance.pop(k, None)
dbm_instance[statement_samples_key] = {'enabled': statement_samples_enabled}
mysql_check = MySql(common.CHECK_NAME, {}, instances=[dbm_instance])
assert mysql_check._statement_samples._enabled == statement_samples_enabled


@pytest.fixture(autouse=True)
def stop_orphaned_threads():
# make sure we shut down any orphaned threads and create a new Executor for each test
Expand Down

0 comments on commit c0d3592

Please sign in to comment.