diff --git a/gprofiler/profilers/java.py b/gprofiler/profilers/java.py index 1002bd9d5..fbba33856 100644 --- a/gprofiler/profilers/java.py +++ b/gprofiler/profilers/java.py @@ -1230,7 +1230,6 @@ def _check_async_profiler_loaded(self, process: Process) -> bool: def _profile_process(self, process: Process, duration: int, spawned: bool) -> ProfileData: comm = process_comm(process) exe = process_exe(process) - container_name = self._profiler_state.get_container_name(process.pid) java_version_output: Optional[str] = get_java_version_logged(process, self._profiler_state.stop_event) if self._enabled_proc_events_java: @@ -1260,6 +1259,7 @@ def _profile_process(self, process: Process, duration: int, spawned: bool) -> Pr self._profiled_pids.add(process.pid) logger.info(f"Profiling{' spawned' if spawned else ''} process {process.pid} with async-profiler") + container_name = self._profiler_state.get_container_name(process.pid) app_metadata = self._metadata.get_metadata(process) appid = application_identifiers.get_java_app_id(process, self._collect_spark_app_name) diff --git a/gprofiler/profilers/php.py b/gprofiler/profilers/php.py index 882592f5c..bab63f266 100644 --- a/gprofiler/profilers/php.py +++ b/gprofiler/profilers/php.py @@ -210,11 +210,10 @@ def extract_metadata_section(re_expr: Pattern, metadata_line: str) -> str: if profiler_state.processes_to_profile is not None: if pid not in [process.pid for process in profiler_state.processes_to_profile]: continue - container_name = profiler_state.get_container_name(pid) # TODO: appid & app metadata for php! appid = None app_metadata = None - profiles[pid] = ProfileData(results[pid], appid, app_metadata, container_name) + profiles[pid] = ProfileData(results[pid], appid, app_metadata, profiler_state.get_container_name(pid)) return profiles diff --git a/gprofiler/profilers/python_ebpf.py b/gprofiler/profilers/python_ebpf.py index 14f24c11b..50aa236b0 100644 --- a/gprofiler/profilers/python_ebpf.py +++ b/gprofiler/profilers/python_ebpf.py @@ -307,9 +307,9 @@ def snapshot(self) -> ProcessToProfileData: if self._profiler_state.processes_to_profile is not None: if process not in self._profiler_state.processes_to_profile: continue - container_name = self._profiler_state.get_container_name(pid) appid = application_identifiers.get_python_app_id(process) app_metadata = self._metadata.get_metadata(process) + container_name = self._profiler_state.get_container_name(pid) except NoSuchProcess: appid = None app_metadata = None diff --git a/gprofiler/utils/__init__.py b/gprofiler/utils/__init__.py index 9410e1792..b8db9c83f 100644 --- a/gprofiler/utils/__init__.py +++ b/gprofiler/utils/__init__.py @@ -325,9 +325,10 @@ def pgrep_maps(match: str) -> List[Process]: # this is much faster than iterating over processes' maps with psutil. # We use flag -E in grep to support systems where grep is not PCRE result = run_process( - ["sh", "-c", f"grep -lE '{match}' /proc/*/maps"], + f"grep -lE '{match}' /proc/*/maps", stdout=subprocess.PIPE, stderr=subprocess.PIPE, + shell=True, suppress_log=True, check=False, pdeathsigger=False, diff --git a/granulate-utils b/granulate-utils index 5866ef2fe..aadebc3a8 160000 --- a/granulate-utils +++ b/granulate-utils @@ -1 +1 @@ -Subproject commit 5866ef2fe75ac7c91c8a05b3df88f6edffd91c9a +Subproject commit aadebc3a8c376ba612f4fb3b78f14d065c35a027