def debugger_stack_trace(event: PodEvent, params: StackTraceParams):
    """
    Prints a stack track of a python process and child threads

    Create a finding with the stack trace results.
    """
    pod = event.get_pod()
    if "debug-toolkit:v6.0" not in PYTHON_DEBUGGER_IMAGE:
        logging.error(f"The debugger_stack_trace action is deprecated and might not work on all platforms. "
                      f"to enable it set the PYTHON_DEBUGGER_IMAGE environment variable to debug-toolkit:v6.0.")
        return
    if not pod:
        logging.info(f"debugger_stack_trace - pod not found for event: {event}")
        return

    process_finder = ProcessFinder(pod, params, ProcessType.PYTHON)
    pid = process_finder.get_lowest_relevant_pid()

    if not pid:
        logging.error("debugger_stack_trace - no relevant pids")
        return

    if params.traces_amount < 1 or params.sleep_duration_s < 0:
        logging.error(
            "debugger_stack_trace - invalid params, "
            "traces_amount must be greater than 1 and sleep_duration_s must be greater than 0"
        )
        return

    # if params pid is set, this will be returned, if not we return the parent process
    finding = Finding(
        title=f"Stacktrace on pid {pid}:",
        source=FindingSource.MANUAL,
        aggregation_key="DebuggerStackTrace",
        subject=PodFindingSubject(pod),
        finding_type=FindingType.REPORT,
        failure=False,
    )
    cmd = (
        f"debug-toolkit stack-trace {pid} --amount={params.traces_amount} --sleep-duration-s={params.sleep_duration_s}"
    )
    output = RobustaPod.exec_in_debugger_pod(
        pod.metadata.name, pod.spec.nodeName, cmd, custom_annotations=params.custom_annotations
    )
    blocks = []
    try:
        output_json = load_json(output)
        SUCCESS_STATUS = "success"
        first_stack_trace_obj = StackTraceObject(**output_json[0]) if len(output_json) >= 1 else None
        if len(output_json) == 0 or (len(output_json) == 1 and first_stack_trace_obj.status != SUCCESS_STATUS):  # type: ignore
            # no stack traces returned or only one with error
            error_message = "Failed to get python stack trace"
            if len(output_json) == 1:
                error_message += f", debugger error {first_stack_trace_obj.error} at " f"{first_stack_trace_obj.trace}"  # type: ignore
            logging.error(error_message)
            blocks.append(MarkdownBlock("Error while getting python stack trace."))
        elif len(output_json) == 1 and first_stack_trace_obj.status == SUCCESS_STATUS:  # type: ignore
            # print single stack trace directly to finding
            for thread_output in first_stack_trace_obj.trace.split("\n\n"):  # type: ignore
                if thread_output.startswith("Current thread"):
                    # this is the thread we are getting the stack trace from, not relevant for debugging
                    continue
                # not printing extra blank lines
                if thread_output:
                    blocks.append(MarkdownBlock(f"```\n{thread_output}\n```"))
        else:
            # print multiple stack traces to file
            clean_output = []
            for trace_object_json in output_json:
                trace_object = StackTraceObject(**trace_object_json)
                if trace_object.status != SUCCESS_STATUS:
                    # the full python stack trace of the error will appear here
                    logging.error(
                        f"Failed to get stack trace, debugger error {trace_object.error} at {trace_object.trace}"
                    )
                    clean_output.append({"time": trace_object.time, "status": "Error: Failed to get stack trace."})
                else:
                    clean_output.append(trace_object_json)
            clean_file_output = json.dumps(clean_output, indent=4, sort_keys=True).replace("\\n", "\n")
            blocks.append(FileBlock(f"debugger_stack_trace_{pid}.txt", clean_file_output.encode()))
    except ValueError:  # includes simplejson.decoder.JSONDecodeError
        logging.error("failed to decode output")
        blocks.append(MarkdownBlock("Failed to processess stack trace(s)"))

    finding.add_enrichment(blocks)
    event.add_finding(finding)

    Prints a stack track of a python process and child threads

    Create a finding with the stack trace results.
    
playbooks/robusta_playbooks/pod_troubleshooting.py