Skip to content

Commit 7fa96d1

Browse files
authored
app ids: Keep original frame (#258)
* app ids: Handle case where -jar is not present in "java" cmdline * merge: Insert the "app id" frame between the "comm" frame and the other frames
1 parent f73b21c commit 7fa96d1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

gprofiler/merge.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,13 @@ def concatenate_profiles(
251251
prefix = (container_name + ";") if add_container_names else ""
252252
for stack, count in stacks.items():
253253
if identify_applications and application_name is not None:
254-
stack = f'{application_name};{stack.split(";", maxsplit=1)[1]}'
254+
application_name = f"appid: {application_name}"
255+
# insert the app name between the first frame and all others
256+
try:
257+
first_frame, others = stack.split(";", maxsplit=1)
258+
stack = f"{first_frame};{application_name};{others}"
259+
except ValueError:
260+
stack = f"{stack};{application_name}"
255261

256262
total_samples += count
257263
lines.append(f"{prefix}{stack} {count}")

gprofiler/metadata/application_identifiers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ def get_application_name(self, process: Process) -> Optional[str]:
214214
if not any("libjvm.so" in m.path for m in process.memory_maps()):
215215
return None
216216

217-
return f"java: {_append_file_to_proc_wd(process, _get_cli_arg_by_name(process.cmdline(), '-jar'))}"
217+
jar_arg = _get_cli_arg_by_name(process.cmdline(), "-jar")
218+
if _NON_AVAILABLE_ARG is None:
219+
return None
220+
221+
return f"java: {_append_file_to_proc_wd(process, jar_arg)}"
218222

219223

220224
# Please note that the order matter, because the FIRST matching identifier will be used.

0 commit comments

Comments
 (0)