From fbf352bd41cbe7ced3941956648dbefaf80f030d Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Fri, 3 Sep 2021 14:48:27 +0200
Subject: [PATCH] L2SS-359: Don't monitor our big 2D arrays

---
 .../tango-prometheus-exporter/code/collector.py        | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/docker-compose/tango-prometheus-exporter/code/collector.py b/docker-compose/tango-prometheus-exporter/code/collector.py
index 970d730a2..9e579788a 100644
--- a/docker-compose/tango-prometheus-exporter/code/collector.py
+++ b/docker-compose/tango-prometheus-exporter/code/collector.py
@@ -65,6 +65,10 @@ class CustomCollector(object):
 
     def add_to_metric_image(self, dev, attr_info, metric):
         attr_value = dev.read_attribute(attr_info.name)
+        if attr_value.dim_x * attr_value.dim_y > 256:
+            # too big, don't monitor
+            return 0
+
         for y in range(int(attr_value.dim_y)): 
             for x in range(int(attr_value.dim_x)):
                 """ NOTE: We switch x and y in the annotation, to allow queries to combine 1D and 2D arrays in their first dimension using the same label (x). We effectively expose
@@ -176,7 +180,7 @@ class CustomCollector(object):
                                 res = self.add_to_metric_spectrum(dev, attr_info, attribute_metrics)
                                 if(res <= 0):
                                     not_managed_attribute_count += 1
-                                    #print("*******NOT MANAGED: "+attr_info.name)
+                                    print("*******NOT MANAGED: "+attr_info.name)
                                 else:
                                     spectrum_count += 1
                                     read_count += 1
@@ -185,14 +189,14 @@ class CustomCollector(object):
                                 res = self.add_to_metric_image(dev, attr_info, attribute_metrics)
                                 if(res <= 0):
                                     not_managed_attribute_count += 1
-                                #print("*******NOT MANAGED: "+attr_info.name)
+                                    print("*******NOT MANAGED: "+attr_info.name)
                                 else:
                                     image_count += 1
                                     read_count += 1
                             else:
                                 # AttrDataFormat.FMT_UNKNOWN
                                 not_managed_attribute_count += 1
-                                #print("*******NOT MANAGED: "+attr_info.name)
+                                print("*******NOT MANAGED: "+attr_info.name)
                         except Exception as e1: 
                             #print ("Could not connect to the '"+ class_list[j] + "." + attr_info.name+"' Attribute.\r\n")
                             #print(e1)
-- 
GitLab