Add property aliasing to Python properties
xmkg opened this issue · comments
Mustafa Kemal Gılor commented
Currently, property names are long because they must be the full import path to the property, e.g.:
@hotsos.core.plugins.kernel.memory.MemInfo.mem_avail_to_mem_total_percentage
The given example property is implemented in the MemInfo class as follows:
hotsos/core/plugins/kernel/memory/MemInfo.py
:
class MemInfo(_BaseProcKeyValue):
# /* .... */
@property
def mem_avail_to_mem_total_percentage(self):
return round((self.MemAvailable * 100) / self.MemTotal)
We could allow aliasing such properties to a shorter, more comprehensible name with a decorator, e.g.:
hotsos/core/plugins/kernel/memory/MemInfo.py
:
class MemInfo(_BaseProcKeyValue):
# /* .... */
@property
@alias('kernel.mem.avail_to_total_pct')
def mem_avail_to_mem_total_percentage(self):
return round((self.MemAvailable * 100) / self.MemTotal)
... so we can refer to it in YAML files like:
@kernel.mem.avail_to_total_pct