Skip to content

Commit

Permalink
Force assertion of a minimun set of metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
hithwen committed Apr 26, 2021
1 parent a687b46 commit 4042230
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 23 deletions.
29 changes: 19 additions & 10 deletions mysql/tests/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,21 @@ def test_minimal_config(aggregator, instance_basic):
aggregator.assert_service_check('mysql.can_connect', status=MySql.OK, tags=tags.SC_TAGS_MIN, count=1)

# Test metrics
testable_metrics = (
variables.STATUS_VARS
+ variables.VARIABLES_VARS
+ variables.INNODB_VARS
+ variables.BINLOG_VARS
+ variables.SYSTEM_METRICS
+ variables.SYNTHETIC_VARS
)
testable_metrics = variables.STATUS_VARS + variables.VARIABLES_VARS + variables.INNODB_VARS + variables.BINLOG_VARS

for mname in testable_metrics:
aggregator.assert_metric(mname, at_least=1)

optional_metrics = (
variables.COMPLEX_STATUS_VARS
+ variables.COMPLEX_VARIABLES_VARS
+ variables.COMPLEX_INNODB_VARS
+ variables.SYSTEM_METRICS
+ variables.SYNTHETIC_VARS
)
_test_optional_metrics(aggregator, optional_metrics)
aggregator.assert_all_metrics_covered()


@pytest.mark.integration
@pytest.mark.usefixtures('dd_environment')
Expand Down Expand Up @@ -98,8 +101,11 @@ def _assert_complex_config(aggregator):
)
testable_metrics = (
variables.STATUS_VARS
+ variables.COMPLEX_STATUS_VARS
+ variables.VARIABLES_VARS
+ variables.COMPLEX_VARIABLES_VARS
+ variables.INNODB_VARS
+ variables.COMPLEX_INNODB_VARS
+ variables.BINLOG_VARS
+ variables.SYSTEM_METRICS
+ variables.SCHEMA_VARS
Expand Down Expand Up @@ -144,7 +150,7 @@ def _assert_complex_config(aggregator):
optional_metrics = (
variables.OPTIONAL_REPLICATION_METRICS
+ variables.OPTIONAL_INNODB_VARS
+ variables.OPTIONAL_STATUS_VARS
+ variables.COMPLEX_STATUS_VARS
+ variables.OPTIONAL_STATUS_VARS_5_6_6
)
# Note, this assertion will pass even if some metrics are not present.
Expand Down Expand Up @@ -193,8 +199,11 @@ def test_complex_config_replica(aggregator, instance_complex):

testable_metrics = (
variables.STATUS_VARS
+ variables.COMPLEX_STATUS_VARS
+ variables.VARIABLES_VARS
+ variables.COMPLEX_VARIABLES_VARS
+ variables.INNODB_VARS
+ variables.COMPLEX_INNODB_VARS
+ variables.BINLOG_VARS
+ variables.SYSTEM_METRICS
+ variables.SCHEMA_VARS
Expand Down Expand Up @@ -232,7 +241,7 @@ def test_complex_config_replica(aggregator, instance_complex):
optional_metrics = (
variables.OPTIONAL_REPLICATION_METRICS
+ variables.OPTIONAL_INNODB_VARS
+ variables.OPTIONAL_STATUS_VARS
+ variables.COMPLEX_STATUS_VARS
+ variables.OPTIONAL_STATUS_VARS_5_6_6
)
# Note, this assertion will pass even if some metrics are not present.
Expand Down
35 changes: 22 additions & 13 deletions mysql/tests/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
# Network Metrics
'mysql.performance.bytes_sent',
'mysql.performance.bytes_received',
# Query Cache Metrics
'mysql.performance.qcache_hits',
'mysql.performance.qcache_inserts',
'mysql.performance.qcache_lowmem_prunes',
# Table Lock Metrics
'mysql.performance.table_locks_waited',
'mysql.performance.table_locks_waited.rate',
Expand All @@ -50,28 +46,31 @@
'mysql.myisam.key_writes',
]

COMPLEX_STATUS_VARS = [
# Query Cache Metrics
'mysql.performance.qcache_hits',
'mysql.performance.qcache_inserts',
'mysql.performance.qcache_lowmem_prunes',
]

# Possibly from SHOW GLOBAL VARIABLES
VARIABLES_VARS = [
'mysql.myisam.key_buffer_size',
'mysql.performance.key_cache_utilization',
'mysql.net.max_connections_available',
'mysql.performance.qcache_size',
'mysql.performance.table_open_cache',
'mysql.performance.thread_cache_size',
]

COMPLEX_VARIABLES_VARS = [
'mysql.performance.qcache_size',
]

INNODB_VARS = [
# InnoDB metrics
'mysql.innodb.data_reads',
'mysql.innodb.data_writes',
'mysql.innodb.os_log_fsyncs',
'mysql.innodb.mutex_spin_waits',
'mysql.innodb.mutex_spin_rounds',
'mysql.innodb.mutex_os_waits',
'mysql.innodb.row_lock_waits',
'mysql.innodb.row_lock_time',
'mysql.innodb.row_lock_current_waits',
# 'mysql.innodb.current_row_locks', MariaDB status
'mysql.innodb.buffer_pool_dirty',
'mysql.innodb.buffer_pool_free',
'mysql.innodb.buffer_pool_used',
Expand All @@ -81,6 +80,16 @@
'mysql.innodb.buffer_pool_utilization',
]

COMPLEX_INNODB_VARS = [
'mysql.innodb.mutex_spin_waits',
'mysql.innodb.mutex_spin_rounds',
'mysql.innodb.mutex_os_waits',
'mysql.innodb.row_lock_waits',
'mysql.innodb.row_lock_time',
'mysql.innodb.row_lock_current_waits',
# 'mysql.innodb.current_row_locks', MariaDB status
]

# Calculated from "SHOW MASTER LOGS;"
BINLOG_VARS = [
# 'mysql.binlog.disk_use', Only collected if log_bin is true
Expand All @@ -98,7 +107,7 @@

# Additional Vars found in "SHOW STATUS;"
# Will collect if [FLAG NAME] is True
OPTIONAL_STATUS_VARS = [
COMPLEX_STATUS_VARS = [
'mysql.binlog.cache_disk_use',
'mysql.binlog.cache_use',
'mysql.binlog.disk_use',
Expand Down

0 comments on commit 4042230

Please sign in to comment.