def _maybe_add_boto_operation_name()

in codeguru_profiler_agent/sampling_utils.py [0:0]


def _maybe_add_boto_operation_name(raw_frame, result):
    """
    boto is dealing with API calls in a very generic way so by default the sampling
    would only show that we are making an api call without having the actual operation name.
    This function checks if this frame is botocore.client.py:_api_call and if it is, it adds
    a frame with the actual operation name.
    :param raw_frame: the raw frame
    """
    if (raw_frame.f_code.co_name == '_api_call'
            and BOTO_CLIENT_PATH.search(raw_frame.f_code.co_filename) is not None
            and raw_frame.f_locals and 'py_operation_name' in raw_frame.f_locals.keys()
            and raw_frame.f_locals.get('py_operation_name')):
        result.append(
            Frame(name=raw_frame.f_locals.get('py_operation_name'),
                  class_name=_extract_class(raw_frame.f_locals),
                  file_path=raw_frame.f_code.co_filename)
        )