Skip to content

Commit

Permalink
Use group name for multigraph report (#4587)
Browse files Browse the repository at this point in the history
Fixes ZEN-29911.
  • Loading branch information
vsaliieva authored Oct 25, 2024
1 parent ea392c5 commit c0d17dc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Products/Zuul/facades/reportfacade.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from Products.Zuul.facades import TreeFacade
from Products.Zuul.interfaces import ITreeFacade, IReportFacade, IMetricServiceGraphDefinition
from Products.Zuul.routers.report import reportTypes, essentialReportOrganizers
from Products.Zuul.infos.metricserver import MultiContextMetricServiceGraphDefinition
from Products.Zuul.infos.metricserver import MultiGraphReportGraphDefinition

_createMethods = [
'manage_addDeviceReport',
Expand Down Expand Up @@ -94,6 +94,6 @@ def getMultiGraphReportDefs(self, uid, graphGroup=None):
info = getMultiAdapter((graphDef['graphDef'], graphDef['context'], graphDef['collection']), IMetricServiceGraphDefinition)
else:
# specialized adapter for combined graph groups
info = MultiContextMetricServiceGraphDefinition(graphDef['graphDef'], graphDef['context'])
info = MultiGraphReportGraphDefinition(graphDef['graphDef'], graphDef['context'], graphDef['collection'])
graphs.append(info)
return graphs
28 changes: 27 additions & 1 deletion Products/Zuul/infos/metricserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def tags(self):

class MultiContextMetricServiceGraphDefinition(MetricServiceGraphDefinition):
"""
This is a specialized adapter for multi graph reports where we have metrics for multiple
This is a specialized adapter where we have metrics for multiple
contexts on a single adapter.
"""
implements(templateInterfaces.IMetricServiceGraphDefinition)
Expand Down Expand Up @@ -414,6 +414,32 @@ def _updateRPNForMultiContext(self, infos, knownDatapointNames):
info.setMultiContextRPN(newRPN)


class MultiGraphReportGraphDefinition(MultiContextMetricServiceGraphDefinition):
"""
This is a specialized adapter for multi graph reports where we have metrics for multiple
contexts on a single adapter.
"""
implements(templateInterfaces.IMetricServiceGraphDefinition)

def __init__(self, graph, context, collection=None):
super(MultiGraphReportGraphDefinition, self).__init__(graph, context)
self._collection = collection

@property
def contextTitle(self):
"""For multi graph reports we need group name in title."""
obj = self._object
if hasattr(obj, "getGraphGroups"):
groupName = next(
(group.titleOrId() for group in obj.getGraphGroups()
if obj.id == group.graphDefId and self._collection.id == group.collectionId),
obj.titleOrId()
)
else:
groupName = obj.titleOrId()
return groupName


class OSProcessMetricServiceGraphDefinition(MetricServiceGraphDefinition):
adapts(GraphDefinition, OSProcess)
implements(templateInterfaces.IMetricServiceGraphDefinition)
Expand Down

0 comments on commit c0d17dc

Please sign in to comment.