Skip to content

Commit

Permalink
Fix discrepancies in batchlog_manager, execution_stages, `io_queu…
Browse files Browse the repository at this point in the history
…e` and `query_processor` metric group names (#5885)

* Fix discrepancies in `batchlog_manager`, `execution_stages`, `io_queue` and `query_processor` metric group names

* Lint

* Update example config

* Keep test for partial additional groups

* Lint
  • Loading branch information
florimondmanca authored Feb 26, 2020
1 parent 94d4fd0 commit 8f90bb4
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 13 deletions.
8 changes: 4 additions & 4 deletions scylla/datadog_checks/scylla/data/conf.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ instances:
#
# metric_groups:
# - scylla.alien
# - scylla.batchlog
# - scylla.batchlog_manager
# - scylla.commitlog
# - scylla.cql
# - scylla.database
# - scylla.execution
# - scylla.execution_stages
# - scylla.hints
# - scylla.httpd
# - scylla.io
# - scylla.io_queue
# - scylla.lsa
# - scylla.memory
# - scylla.memtables
# - scylla.query
# - scylla.query_processor
# - scylla.scheduler
# - scylla.sstables
# - scylla.thrift
Expand Down
16 changes: 8 additions & 8 deletions scylla/datadog_checks/scylla/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'scylla_alien_total_sent_messages': 'alien.total_sent_messages',
}

SCYLLA_BATCHLOG = {
SCYLLA_BATCHLOG_MANAGER = {
'scylla_batchlog_manager_total_write_replay_attempts': 'batchlog_manager.total_write_replay_attempts',
}

Expand Down Expand Up @@ -138,7 +138,7 @@
'scylla_database_view_update_backlog': 'database.view_update_backlog',
}

SCYLLA_EXECUTION = {
SCYLLA_EXECUTION_STAGES = {
'scylla_execution_stages_function_calls_enqueued': 'execution_stages.function_calls_enqueued',
'scylla_execution_stages_function_calls_executed': 'execution_stages.function_calls_executed',
'scylla_execution_stages_tasks_preempted': 'execution_stages.tasks_preempted',
Expand Down Expand Up @@ -174,7 +174,7 @@
'scylla_httpd_requests_served': 'httpd.requests_served',
}

SCYLLA_IO = {
SCYLLA_IO_QUEUE = {
'scylla_io_queue_delay': 'io_queue.delay',
'scylla_io_queue_queue_length': 'io_queue.queue_length',
'scylla_io_queue_shares': 'io_queue.shares',
Expand Down Expand Up @@ -225,7 +225,7 @@
'scylla_node_operation_mode': 'node.operation_mode',
}

SCYLLA_QUERY = {
SCYLLA_QUERY_PROCESSOR = {
'scylla_query_processor_queries': 'query_processor.queries',
'scylla_query_processor_statements_prepared': 'query_processor.statements_prepared',
}
Expand Down Expand Up @@ -376,18 +376,18 @@

ADDITIONAL_METRICS_MAP = {
'scylla.alien': SCYLLA_ALIEN,
'scylla.batchlog': SCYLLA_BATCHLOG,
'scylla.batchlog_manager': SCYLLA_BATCHLOG_MANAGER,
'scylla.commitlog': SCYLLA_COMMITLOG,
'scylla.cql': SCYLLA_CQL,
'scylla.database': SCYLLA_DATABASE,
'scylla.execution': SCYLLA_EXECUTION,
'scylla.execution_stages': SCYLLA_EXECUTION_STAGES,
'scylla.hints': SCYLLA_HINTS,
'scylla.httpd': SCYLLA_HTTPD,
'scylla.io': SCYLLA_IO,
'scylla.io_queue': SCYLLA_IO_QUEUE,
'scylla.lsa': SCYLLA_LSA,
'scylla.memory': SCYLLA_MEMORY,
'scylla.memtables': SCYLLA_MEMTABLES,
'scylla.query': SCYLLA_QUERY,
'scylla.query_processor': SCYLLA_QUERY_PROCESSOR,
'scylla.scheduler': SCYLLA_SCHEDULER,
'scylla.sstables': SCYLLA_SSTABLES,
'scylla.thrift': SCYLLA_THRIFT,
Expand Down
22 changes: 22 additions & 0 deletions scylla/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,32 @@
]


INSTANCE_ADDITIONAL_GROUPS = [
'scylla.alien',
'scylla.batchlog_manager',
'scylla.commitlog',
'scylla.cql',
'scylla.database',
'scylla.execution_stages',
'scylla.hints',
'scylla.httpd',
'scylla.io_queue',
'scylla.lsa',
'scylla.memory',
'scylla.memtables',
'scylla.query_processor',
'scylla.scheduler',
'scylla.sstables',
'scylla.thrift',
'scylla.tracing',
]


# expand the lists into a single list of metrics
def get_metrics(metric_groups):
"""Given a list of metric groups, return single consolidated list"""
return sorted(m for g in metric_groups for m in INSTANCE_METRIC_GROUP_MAP[g])


INSTANCE_DEFAULT_METRICS = get_metrics(INSTANCE_DEFAULT_GROUPS)
INSTANCE_ADDITIONAL_METRICS = get_metrics(INSTANCE_ADDITIONAL_GROUPS)
25 changes: 24 additions & 1 deletion scylla/tests/test_scylla.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
from datadog_checks.base.errors import CheckException, ConfigurationError
from datadog_checks.scylla import ScyllaCheck

from .common import INSTANCE_DEFAULT_GROUPS, INSTANCE_DEFAULT_METRICS, get_metrics
from .common import (
INSTANCE_ADDITIONAL_GROUPS,
INSTANCE_ADDITIONAL_METRICS,
INSTANCE_DEFAULT_GROUPS,
INSTANCE_DEFAULT_METRICS,
get_metrics,
)


@pytest.mark.unit
Expand Down Expand Up @@ -42,6 +48,23 @@ def test_instance_additional_check(aggregator, db_instance, mock_db_data):
aggregator.assert_service_check('scylla.prometheus.health', count=1)


@pytest.mark.unit
def test_instance_full_additional_check(aggregator, db_instance, mock_db_data):
instance = deepcopy(db_instance)
instance['metric_groups'] = INSTANCE_ADDITIONAL_GROUPS

c = ScyllaCheck('scylla', {}, [instance])

c.check(instance)

metrics_to_check = INSTANCE_DEFAULT_METRICS + INSTANCE_ADDITIONAL_METRICS

for m in metrics_to_check:
aggregator.assert_metric(m)
aggregator.assert_all_metrics_covered()
aggregator.assert_service_check('scylla.prometheus.health', count=1)


@pytest.mark.unit
def test_instance_invalid_group_check(aggregator, db_instance, mock_db_data):
additional_metric_groups = ['scylla.bogus', 'scylla.sstables']
Expand Down

0 comments on commit 8f90bb4

Please sign in to comment.