Automate the CPS-NCMP metrics scraping 87/140787/6
authorhalil.cakal <halil.cakal@est.tech>
Thu, 24 Apr 2025 08:47:57 +0000 (09:47 +0100)
committerhalil.cakal <halil.cakal@est.tech>
Thu, 24 Apr 2025 15:41:09 +0000 (16:41 +0100)
- import ScrapeMetrics, test_ScrapeMetrics and run from conf .py to
  automate the scraping
- the scripts will be running with tox when building the docs
- update unit tests to use test specific names
- highlight the header row of metrics' table

Issue-ID: CPS-2778

Change-Id: I843221ec21454220ea1182c488f88813c0691c4a
Signed-off-by: halil.cakal <halil.cakal@est.tech>
docs/admin-guide.rst
docs/conf.py
docs/test_ScrapeMetrics.py

index 447a171..8f0634a 100644 (file)
@@ -225,6 +225,7 @@ Below table lists all CPS-NCMP custom metrics
 .. csv-table::
     :file: csv/metrics.csv
     :widths: 50, 50
+    :header-rows: 1
 
 Prometheus Metrics can be checked at the following endpoint
 
index 364efe8..d3ec5df 100755 (executable)
@@ -1,5 +1,5 @@
 #  ============LICENSE_START=======================================================
-#  Copyright (C) 2021 Nordix Foundation
+#  Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
 #  ================================================================================
 #  Licensed under the Apache License, Version 2.0 (the "License");
 #  you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
 
 from docutils.parsers.rst import directives
 
+import subprocess
+
 project = "onap"
 release = "master"
 version = "master"
@@ -69,6 +71,12 @@ linkcheck_ignore = [
 
 html_last_updated_fmt = '%d-%b-%y %H:%M'
 
+# Run ScrapeMetrics.py
+subprocess.run(["python3", "ScrapeMetrics.py"], check=True)
+
+# Run test_ScrapeMetrics.py
+subprocess.run(["python3", "test_ScrapeMetrics.py"], check=True)
+
 
 def setup(app):
     app.add_css_file("css/ribbon.css")
index 62365fd..cbcc92d 100644 (file)
@@ -55,7 +55,7 @@ class TestScrapeMetrics(unittest.TestCase):
             @Timed(value="timed", description="A timed metric")
             public void anotherMethod() {}
 
-            @TimedCustom(name="cps_ncmp_inventory_cm_handles_by_state{state=DELETING}", description="A custom timed metric")
+            @TimedCustom(name="custom counter name", description="A custom timed metric")
             public void anotherMethod() {}
 
             @NotTimed
@@ -65,7 +65,7 @@ class TestScrapeMetrics(unittest.TestCase):
         expected_metrics = [
             '"cm_handle_search_invocation_total","A description does not fit the a single line"',
             '"timed","A timed metric"',
-            '"cps_ncmp_inventory_cm_handles_by_state{state=DELETING}","A custom timed metric"'
+            '"custom counter name","A custom timed metric"'
         ]
         result = scrape_all_metrics_from_file(test_file)
         self.assertEqual(len(result), 3)