Make required events a set

This commit is contained in:
Christophe Bedard 2019-12-31 13:19:31 -05:00
parent 938cc263d5
commit e374419665
4 changed files with 18 additions and 17 deletions

View file

@ -138,14 +138,14 @@ class EventHandler(Dependant):
return None
@staticmethod
def required_events() -> List[str]:
def required_events() -> Set[str]:
"""
Get the list of events required by this EventHandler.
Get the set of events required by this EventHandler.
Without these events, the EventHandler would be invalid/useless. Inheriting classes can
decide not to declare that they require specific events.
"""
return []
return {}
def register_processor(self, processor: 'Processor') -> None:
"""Register processor with this `EventHandler` so that it can query other handlers."""

View file

@ -15,7 +15,7 @@
"""Module for CPU time events processing."""
from typing import Dict
from typing import List
from typing import Set
from tracetools_read import get_field
@ -53,10 +53,10 @@ class CpuTimeHandler(EventHandler):
self._cpu_start: Dict[int, int] = {}
@staticmethod
def required_events() -> List[str]:
return [
def required_events() -> Set[str]:
return {
'sched_switch',
]
}
@property
def data(self) -> CpuTimeDataModel:

View file

@ -15,7 +15,7 @@
"""Module for memory usage events processing."""
from typing import Dict
from typing import List
from typing import Set
from tracetools_read import get_field
@ -98,11 +98,11 @@ class UserspaceMemoryUsageHandler(MemoryUsageHandler):
self._memory: Dict[int, int] = {}
@staticmethod
def required_events() -> List[str]:
return [
def required_events() -> Set[str]:
return {
'lttng_ust_libc:malloc',
'lttng_ust_libc:free',
]
}
def _handle_malloc(
self, event: Dict, metadata: EventMetadata
@ -209,11 +209,11 @@ class KernelMemoryUsageHandler(MemoryUsageHandler):
)
@staticmethod
def required_events() -> List[str]:
return [
def required_events() -> Set[str]:
return {
'kmem_mm_page_alloc',
'kmem_mm_page_free',
]
}
def _handle_malloc(
self, event: Dict, metadata: EventMetadata

View file

@ -17,6 +17,7 @@
from collections import defaultdict
from typing import Dict
from typing import List
from typing import Set
from typing import Union
from tracetools_read import get_field
@ -87,12 +88,12 @@ class ProfileHandler(EventHandler):
self._current_funcs: Dict[int, List[List[Union[str, int]]]] = defaultdict(list)
@staticmethod
def required_events() -> List[str]:
return [
def required_events() -> Set[str]:
return {
'lttng_ust_cyg_profile_fast:func_entry',
'lttng_ust_cyg_profile_fast:func_exit',
'sched_switch',
]
}
@staticmethod
def addr_to_int(addr: Union[int, str]) -> int: