Skip to content

Commit 3cabf9e

Browse files
authored
Tag FoundationDB process metrics with process class, assigned roles (#19682)
* Tag FoundationDB process metrics with process class, assigned roles * Test that FoundationDB process metrics are tagged with process class and role
1 parent b1aec8d commit 3cabf9e

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

foundationdb/changelog.d/19682.added

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Tag FoundationDB process metrics with process class, assigned roles

foundationdb/datadog_checks/foundationdb/check.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ def report_process(self, process):
9393
return
9494
tags = self._tags + ["fdb_process:" + process["address"]]
9595

96+
if "class_type" in process:
97+
tags.append("fdb_process_class:" + process["class_type"])
98+
99+
if "roles" in process:
100+
# First, report role-specific metrics before we add role tags to the list…
101+
for role in process["roles"]:
102+
self.report_role(role, tags)
103+
104+
# …then add role tags so we can associate process metrics with roles.
105+
for role in process["roles"]:
106+
if "role" in role:
107+
tags.append("fdb_role:" + role["role"])
108+
96109
if "cpu" in process:
97110
self.maybe_gauge("process.cpu.usage_cores", process["cpu"], "usage_cores", tags)
98111
if "disk" in process:
@@ -122,10 +135,6 @@ def report_process(self, process):
122135
self.maybe_hz_counter("process.network.megabits_sent", network, "megabits_sent", tags)
123136
self.maybe_hz_counter("process.network.tls_policy_failures", network, "tls_policy_failures", tags)
124137

125-
if "roles" in process:
126-
for role in process["roles"]:
127-
self.report_role(role, tags)
128-
129138
def report_role(self, role, process_tags):
130139
if "role" not in role:
131140
return

foundationdb/tests/test_foundationdb.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,29 @@ def test_full(aggregator, instance):
3636
aggregator.assert_metric(metric)
3737
aggregator.assert_metric_has_tag(metric, 'fdb_test:true')
3838

39+
if metric.startswith('foundationdb.process.'):
40+
aggregator.assert_metric_has_tag_prefix(metric, 'fdb_process_class')
41+
aggregator.assert_metric_has_tag_prefix(metric, 'fdb_role')
42+
43+
aggregator.assert_metric(
44+
'foundationdb.process.cpu.usage_cores',
45+
tags=[
46+
'fdb_test:true',
47+
'fdb_process:127.0.0.1:4000',
48+
'fdb_process_class:unset',
49+
'fdb_role:master',
50+
'fdb_role:cluster_controller',
51+
'fdb_role:data_distributor',
52+
'fdb_role:ratekeeper',
53+
'fdb_role:coordinator',
54+
'fdb_role:proxy',
55+
'fdb_role:log',
56+
'fdb_role:storage',
57+
'fdb_role:resolver',
58+
],
59+
value=0.015280199999999999,
60+
)
61+
3962
aggregator.assert_all_metrics_covered()
4063
aggregator.assert_metrics_using_metadata(get_metadata_metrics())
4164
aggregator.assert_service_check("foundationdb.can_connect", AgentCheck.OK)

0 commit comments

Comments
 (0)