Add logs for trace action init and fini
This commit is contained in:
parent
c2776febad
commit
2e9b2b7ee8
3 changed files with 15 additions and 4 deletions
|
@ -18,6 +18,7 @@ import re
|
|||
from typing import List
|
||||
from typing import Optional
|
||||
|
||||
from launch import logging
|
||||
from launch.action import Action
|
||||
from launch.event import Event
|
||||
from launch.event_handlers import OnShutdown
|
||||
|
@ -75,6 +76,7 @@ class Trace(Action):
|
|||
self.__events_kernel = events_kernel
|
||||
self.__context_names = context_names
|
||||
self.__profile_fast = profile_fast
|
||||
self.__logger = logging.get_logger(__name__)
|
||||
self.__ld_preload_actions = []
|
||||
# Add LD_PRELOAD actions if corresponding events are enabled
|
||||
if self.has_profiling_events(self.__events_ust):
|
||||
|
@ -124,15 +126,17 @@ class Trace(Action):
|
|||
return self.__ld_preload_actions
|
||||
|
||||
def _setup(self) -> None:
|
||||
lttng.lttng_init(
|
||||
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 _destroy(self, event: Event, context: LaunchContext) -> None:
|
||||
self.__logger.debug(f'Finalizing tracing session: {self.__session_name}')
|
||||
lttng.lttng_fini(self.__session_name)
|
||||
|
||||
def __repr__(self):
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
"""Interface for tracing with LTTng."""
|
||||
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
|
||||
try:
|
||||
from . import lttng_impl
|
||||
|
@ -38,7 +39,7 @@ def lttng_init(
|
|||
ros_events: List[str] = DEFAULT_EVENTS_ROS,
|
||||
kernel_events: List[str] = DEFAULT_EVENTS_KERNEL,
|
||||
context_names: List[str] = DEFAULT_CONTEXT,
|
||||
) -> None:
|
||||
) -> Optional[str]:
|
||||
"""
|
||||
Set up and start LTTng session.
|
||||
|
||||
|
@ -47,9 +48,11 @@ def lttng_init(
|
|||
:param ros_events: list of ROS events to enable
|
||||
:param kernel_events: list of kernel events to enable
|
||||
:param context_names: list of context elements to enable
|
||||
:return: the full path to the trace directory
|
||||
"""
|
||||
_lttng.setup(session_name, base_path, ros_events, kernel_events, context_names)
|
||||
trace_directory = _lttng.setup(session_name, base_path, ros_events, kernel_events, context_names)
|
||||
_lttng.start(session_name)
|
||||
return trace_directory
|
||||
|
||||
|
||||
def lttng_fini(
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
"""Implementation of the interface for tracing with LTTng."""
|
||||
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
|
||||
import lttng
|
||||
|
||||
|
@ -33,7 +34,7 @@ def setup(
|
|||
context_names: List[str] = DEFAULT_CONTEXT,
|
||||
channel_name_ust: str = 'ros2',
|
||||
channel_name_kernel: str = 'kchan',
|
||||
) -> None:
|
||||
) -> Optional[str]:
|
||||
"""
|
||||
Set up LTTng session, with events and context.
|
||||
|
||||
|
@ -46,6 +47,7 @@ def setup(
|
|||
:param context_names: list of context elements to enable
|
||||
:param channel_name_ust: the UST channel name
|
||||
:param channel_name_kernel: the kernel channel name
|
||||
:return: the full path to the trace directory
|
||||
"""
|
||||
# Resolve full tracing directory path
|
||||
full_path = get_full_session_path(session_name, base_path=base_path)
|
||||
|
@ -113,6 +115,8 @@ def setup(
|
|||
enabled_handles = [h for h in [handle_ust, handle_kernel] if h is not None]
|
||||
_add_context(enabled_handles, context_list)
|
||||
|
||||
return full_path
|
||||
|
||||
|
||||
def start(
|
||||
session_name: str,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue