def init(args): """ Init and start tracing. :param args: the parsed arguments object containing the right fields """ session_name = args.session_name base_path = args.path ros_events = args.events_ust kernel_events = args.events_kernel ust_enabled = len(ros_events) > 0 kernel_enabled = len(kernel_events) > 0 if ust_enabled: print(f'UST tracing enabled ({len(ros_events)} events)') if args.list: print_events_list(ros_events) else: print('UST tracing disabled') if kernel_enabled: print(f'kernel tracing enabled ({len(kernel_events)} events)') if args.list: print_events_list(kernel_events) else: print('kernel tracing disabled') full_session_path = path.get_full_session_path(session_name, base_path) print(f'writing tracing session to: {full_session_path}') input('press enter to start...') lttng.lttng_init(session_name, base_path=base_path, ros_events=ros_events, kernel_events=kernel_events)
def main(): params = args.parse_args() session_name = params.session_name base_path = params.path ros_events = params.events_ust kernel_events = params.events_kernel ust_enabled = len(ros_events) > 0 kernel_enabled = len(kernel_events) > 0 if ust_enabled: print(f'UST tracing enabled ({len(ros_events)} events)') if params.list: print_events_list(ros_events) else: print('UST tracing disabled') if kernel_enabled: print(f'kernel tracing enabled ({len(kernel_events)} events)') if params.list: print_events_list(kernel_events) else: print('kernel tracing disabled') full_session_path = path.get_full_session_path(session_name, base_path) print(f'writing tracing session to: {full_session_path}') input('press enter to start...') lttng.lttng_init(session_name, base_path=base_path, ros_events=ros_events, kernel_events=kernel_events) input('press enter to stop...') print('stopping & destroying tracing session') lttng.lttng_fini(session_name)
def init( session_name: str, base_path: str, ros_events: List[str], kernel_events: List[str], context_names: List[str], display_list: bool = False, ) -> None: """ Init and start tracing. :param session_name: the name of the session :param base_path: the path to the directory in which to create the tracing session directory :param ros_events: list of ROS events to enable :param kernel_events: list of kernel events to enable :param context_names: list of context names to enable :param display_list: whether to display list(s) of enabled events and context names """ if not lttng.is_lttng_installed(): sys.exit(2) ust_enabled = len(ros_events) > 0 kernel_enabled = len(kernel_events) > 0 if ust_enabled: print(f'UST tracing enabled ({len(ros_events)} events)') if display_list: print_names_list(ros_events) else: print('UST tracing disabled') if kernel_enabled: print(f'kernel tracing enabled ({len(kernel_events)} events)') if display_list: print_names_list(kernel_events) else: print('kernel tracing disabled') if len(context_names) > 0: print(f'context ({len(context_names)} names)') if display_list: print_names_list(context_names) full_session_path = path.get_full_session_path(session_name, base_path) print(f'writing tracing session to: {full_session_path}') input('press enter to start...') lttng.lttng_init( session_name, base_path=base_path, ros_events=ros_events, kernel_events=kernel_events, context_names=context_names, )
def _setup(self) -> None: trace_directory = lttng.lttng_init( self.__session_name, self.__base_path, ros_events=self.__events_ust, kernel_events=self.__events_kernel, context_names=self.__context_names, ) self.__logger.info(f'Writing tracing session to: {trace_directory}')
def _setup(self) -> bool: self.__trace_directory = lttng.lttng_init( session_name=self.__session_name, base_path=self.__base_path, ros_events=self.__events_ust, kernel_events=self.__events_kernel, context_fields=self.__context_fields, ) if self.__trace_directory is None: return False self.__logger.info( f'Writing tracing session to: {self.__trace_directory}') self.__logger.debug(f'UST events: {self.__events_ust}') self.__logger.debug(f'Kernel events: {self.__events_kernel}') self.__logger.debug(f'Context fields: {self.__context_fields}') self.__logger.debug(f'LD_PRELOAD: {self.__ld_preload_actions}') return True
def test_lttng_not_installed(self): from tracetools_trace.tools.lttng import lttng_init with mock.patch('tracetools_trace.tools.lttng.is_lttng_installed', return_value=False): self.assertIsNone( lttng_init(session_name='test-session', base_path='/tmp'))
def init( *, session_name: str, base_path: Optional[str], ros_events: List[str], kernel_events: List[str], context_fields: List[str], display_list: bool = False, ) -> bool: """ Init and start tracing. :param session_name: the name of the session :param base_path: the path to the directory in which to create the tracing session directory, or `None` for default :param ros_events: list of ROS events to enable :param kernel_events: list of kernel events to enable :param context_fields: list of context fields to enable :param display_list: whether to display list(s) of enabled events and context names :return: True if successful, False otherwise """ # Check if LTTng is installed right away before printing anything if not lttng.is_lttng_installed(): sys.exit(2) ust_enabled = len(ros_events) > 0 kernel_enabled = len(kernel_events) > 0 if ust_enabled: print(f'UST tracing enabled ({len(ros_events)} events)') if display_list: print_names_list(ros_events) else: print('UST tracing disabled') if kernel_enabled: print(f'kernel tracing enabled ({len(kernel_events)} events)') if display_list: print_names_list(kernel_events) else: print('kernel tracing disabled') if len(context_fields) > 0: print(f'context ({len(context_fields)} names)') if display_list: print_names_list(context_fields) if not base_path: base_path = path.get_tracing_directory() full_session_path = os.path.join(base_path, session_name) print(f'writing tracing session to: {full_session_path}') input('press enter to start...') trace_directory = lttng.lttng_init( session_name=session_name, base_path=base_path, ros_events=ros_events, kernel_events=kernel_events, context_fields=context_fields, ) if trace_directory is None: return False # Simple sanity check assert trace_directory == full_session_path return True
def _setup(self) -> None: lttng.lttng_init( self.__session_name, self.__base_path, ros_events=self.__events_ust, kernel_events=self.__events_kernel)