Skip to content

Commit 46016aa

Browse files
Update the runtime metrics test cases to check both gauges and distributions for metrics
1 parent 48adbde commit 46016aa

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

tests/test_config_consistency.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,21 @@ def setup_main(self):
569569
def test_main(self):
570570
assert self.req.status_code == 200
571571

572-
runtime_metrics = [
572+
runtime_metrics_gauges = [
573573
metric
574574
for _, metric in interfaces.agent.get_metrics()
575575
if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.")
576576
]
577-
assert len(runtime_metrics) > 0
577+
578+
runtime_metrics_sketches = [
579+
metric
580+
for _, metric in interfaces.agent.get_sketches()
581+
if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.")
582+
]
583+
584+
assert len(runtime_metrics_gauges) > 0 or len(runtime_metrics_sketches) > 0
585+
586+
runtime_metrics = runtime_metrics_gauges if len(runtime_metrics_gauges) > 0 else runtime_metrics_sketches
578587

579588
for metric in runtime_metrics:
580589
tags = {tag.split(":")[0]: tag.split(":")[1] for tag in metric["tags"]}
@@ -605,12 +614,21 @@ def setup_main(self):
605614
def test_main(self):
606615
assert self.req.status_code == 200
607616

608-
runtime_metrics = [
617+
runtime_metrics_gauges = [
609618
metric
610619
for _, metric in interfaces.agent.get_metrics()
611620
if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.")
612621
]
613-
assert len(runtime_metrics) > 0
622+
623+
runtime_metrics_sketches = [
624+
metric
625+
for _, metric in interfaces.agent.get_sketches()
626+
if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.")
627+
]
628+
629+
assert len(runtime_metrics_gauges) > 0 or len(runtime_metrics_sketches) > 0
630+
631+
runtime_metrics = runtime_metrics_gauges if len(runtime_metrics_gauges) > 0 else runtime_metrics_sketches
614632

615633
for metric in runtime_metrics:
616634
tags = {tag.split(":")[0]: tag.split(":")[1] for tag in metric["tags"]}
@@ -633,12 +651,19 @@ def setup_main(self):
633651
def test_main(self):
634652
assert self.req.status_code == 200
635653

636-
runtime_metrics = [
654+
runtime_metrics_gauges = [
637655
metric
638656
for _, metric in interfaces.agent.get_metrics()
639657
if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.")
640658
]
641-
assert len(runtime_metrics) == 0
659+
660+
runtime_metrics_sketches = [
661+
metric
662+
for _, metric in interfaces.agent.get_sketches()
663+
if metric["metric"].startswith("runtime.") or metric["metric"].startswith("jvm.")
664+
]
665+
666+
assert len(runtime_metrics_gauges) == 0 and len(runtime_metrics_sketches) == 0
642667

643668

644669
# Parse the JSON-formatted log message from stdout and return the 'dd' object

0 commit comments

Comments
 (0)