]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: add checks for histograms with unique schema
authorLaura Flores <lflores@redhat.com>
Thu, 5 Aug 2021 22:11:25 +0000 (22:11 +0000)
committerLaura Flores <lflores@redhat.com>
Thu, 5 Aug 2021 22:11:25 +0000 (22:11 +0000)
In some cases, the user might change the configuration of a certain histogram, such as its bucket size. To handle this, I wrote a check that separates histograms with unique configurations so there are no conflicts. Histograms with like configs are combined.

Signed-off-by: Laura Flores <lflores@redhat.com>
src/pybind/mgr/telemetry/module.py

index d29c4f0edd0d63cc8d0799b584c4e389b8bea8db..a5c8cc6200d53ecdf3bc6b57a7dc64370dfef956 100644 (file)
@@ -394,9 +394,6 @@ class Module(MgrModule):
                             axis_dict: Dict[str, Any] = defaultdict()
 
                             # Collecting information for buckets, min, name, etc.
-                            # TODO: In some cases, the user might change the size of
-                            # their buckets. A check needs to be written that separates
-                            # out histograms with unique bucket sizes.
                             axis_dict['buckets'] = axis['buckets']
                             axis_dict['min'] = axis['min']
                             axis_dict['name'] = axis['name']
@@ -422,7 +419,12 @@ class Module(MgrModule):
                             axes.append(axis_dict)
 
                         # Add the 'axes' list, containing both axes, to result.
-                        result['osd'][histogram]['axes'] = axes
+                        # At this point, you will see that the name of the key is the string
+                        # form of our axes list (str(axes)). This is there so that histograms
+                        # with different axis configs will not be combined.
+                        # The key names are modified into something more readable ('config_x')
+                        # down below.
+                        result[str(axes)][histogram]['axes'] = axes
 
                         # Collect current values and make sure they are in
                         # integer form.
@@ -432,13 +434,19 @@ class Module(MgrModule):
 
                         # Aggregate values. If 'values' have already been initialized,
                         # we can safely add.
-                        if 'values' in result['osd'][histogram]:
+                        if 'values' in result[str(axes)][histogram]:
                             for i in range (0, len(values)):
                                 for j in range (0, len(values[i])):
-                                    values[i][j] += result['osd'][histogram]['values'][i][j]
+                                    values[i][j] += result[str(axes)][histogram]['values'][i][j]
 
                         # Add the values to result.
-                        result['osd'][histogram]['values'] = values
+                        result[str(axes)][histogram]['values'] = values
+
+                        # Update num_combined_osds
+                        if 'num_combined_osds' not in result[str(axes)][histogram]:
+                            result[str(axes)][histogram]['num_combined_osds'] = 1
+                        else:
+                            result[str(axes)][histogram]['num_combined_osds'] += 1
 
                 # Sometimes, json errors occur if you give it an empty string.
                 # I am also putting in a catch for a KeyError since it could
@@ -449,6 +457,15 @@ class Module(MgrModule):
                     self.log.debug("Error caught: {}".format(e))
                     return {}
 
+        # Update result key names. The key names are currently very complicated
+        # axis configurations, such that histograms with like axis configurations are
+        # combined. However, to make the final report more readable, I will update
+        # the key names to "config_1", "config_2", etc.
+        config_num = 1
+        for k, v in list(result.items()):
+            result['config_' + str(config_num)] = result.pop(k)
+            config_num += 1
+
         return result
 
     def get_io_rate(self) -> dict:
@@ -1014,16 +1031,18 @@ Please consider enabling the telemetry module with 'ceph telemetry on'.'''
         # ranges and values, which are currently in list form, into strings so that
         # they are displayed horizontally instead of vertically.
         try:
-            for histogram in report['osd_perf_histograms']['osd']:
-                # Adjust ranges by converting lists into strings
-                for axis in report['osd_perf_histograms']['osd'][histogram]['axes']:
-                    for i in range(0, len(axis['ranges'])):
-                        axis['ranges'][i] = str(axis['ranges'][i])
-
-                # Adjust values also by converting lists into strings
-                for i in range(0, len(report['osd_perf_histograms']['osd'][histogram]['values'])):
-                    report['osd_perf_histograms']['osd'][histogram]['values'][i] = \
-                            str(report['osd_perf_histograms']['osd'][histogram]['values'][i])
+            for config in report['osd_perf_histograms']:
+                for histogram in report['osd_perf_histograms'][config]:
+
+                    # Adjust ranges by converting lists into strings
+                    for axis in report['osd_perf_histograms'][config][histogram]['axes']:
+                        for i in range(0, len(axis['ranges'])):
+                            axis['ranges'][i] = str(axis['ranges'][i])
+
+                    # Adjust values by converting lists into strings
+                    for i in range(0, len(report['osd_perf_histograms'][config][histogram]['values'])):
+                        report['osd_perf_histograms'][config][histogram]['values'][i] = \
+                                str(report['osd_perf_histograms'][config][histogram]['values'][i])
         except KeyError:
             # If the perf channel is not enabled, there should be a KeyError since
             # 'osd_perf_histograms' would not be present in the report. In that case,