@@ -36,6 +36,7 @@ class Topo(object):
36
36
def __init__ (self , jsonStr = None ):
37
37
self .topo = jsonStr
38
38
self .__metricsDef = defaultdict (dict ) # metrics dictionary, per sensor for all elements in the metadata
39
+ self .__metricsType = defaultdict (dict ) # metrics types dictionary
39
40
self .__levels = defaultdict (dict ) # component level priority dictionary, per sensor
40
41
self .__ids = {} # fieldIds dictionary
41
42
self .__groupKeys = {}
@@ -62,15 +63,15 @@ def _processMetadata(self, metadata):
62
63
_components = self .__compTree [label ]['componentsMap' ]
63
64
_filters = self .__compTree [label ]['filtersMap' ]
64
65
65
- self ._parse_topoJSONStr (self .__metricsDef , self .__levels , self .__ids , self .__groupKeys , _components , _filters , metaStr )
66
+ self ._parse_topoJSONStr (self .__metricsDef , self .__metricsType , self . __levels , self .__ids , self .__groupKeys , _components , _filters , metaStr )
66
67
tree_entry = {}
67
68
tree_entry ['componentsMap' ] = _components
68
69
tree_entry ['filtersMap' ] = _filters
69
70
70
71
# comp_tree[label] = tree_entry
71
72
self .__compTree [label ] = tree_entry
72
73
73
- def _parse_topoJSONStr (self , metrics , levels , ids , groupKeys , components , filters , metaStr ):
74
+ def _parse_topoJSONStr (self , metrics , metricsType , levels , ids , groupKeys , components , filters , metaStr ):
74
75
'''
75
76
This function parses the 'node' or 'attribute' object found in the given JSON string (metaStr) in
76
77
the componets or metrics dictionary. Also the used metric filters (per sensor) will be stored
@@ -80,6 +81,7 @@ def _parse_topoJSONStr(self, metrics, levels, ids, groupKeys, components, filter
80
81
81
82
field_value = metaStr ['fieldLabel' ]
82
83
field_name = metaStr ['fieldName' ]
84
+ field_type = metaStr ['fieldSemantics' ]
83
85
84
86
# check if entity is a component
85
87
if metaStr ['type' ] == 'node' :
@@ -88,7 +90,7 @@ def _parse_topoJSONStr(self, metrics, levels, ids, groupKeys, components, filter
88
90
# check if metaStr includes next level metaStr
89
91
if 'keys' in metaStr and len (metaStr ['keys' ]) > 0 :
90
92
for metaKey in metaStr ['keys' ]:
91
- self ._parse_topoJSONStr (metrics , levels , ids , groupKeys , components , filters , metaKey )
93
+ self ._parse_topoJSONStr (metrics , metricsType , levels , ids , groupKeys , components , filters , metaKey )
92
94
93
95
# check if entity is a metric
94
96
elif metaStr ['type' ] == 'attribute' :
@@ -100,6 +102,7 @@ def _parse_topoJSONStr(self, metrics, levels, ids, groupKeys, components, filter
100
102
101
103
if field_name not in iterval (metrics [sensor ]):
102
104
metrics [sensor ][field_id ] = field_name
105
+ metricsType [field_name ] = field_type
103
106
104
107
if groupKey not in groupKeys :
105
108
# parse sensor relevant data f.e. groupKey, filters, levels
@@ -177,6 +180,11 @@ def metricsSpec(self):
177
180
''' Returns all defined metrics as dictionary of (metric_name : metric_id) items '''
178
181
return self .__metricsDef
179
182
183
+ @property
184
+ def metricsType (self ):
185
+ ''' Returns a dictionary of (metric_name : metric_type) items '''
186
+ return self .__metricsType
187
+
180
188
@property
181
189
def getAllEnabledMetricsNames (self ):
182
190
''' Returns list of all found metrics names'''
0 commit comments