def trace_generic_hybrid_worker_event(event_id, task_name, message, t_id, keyword, activity_id=None, debug=False): """Write the trace to STDOUT / log file (on disk) / to MDS (in the cloud). Args: event_id : int , the event id. This event id doesn't have to map to an ETW event id in the cloud. task_name : string, the task name. message : string, the message. t_id : int , the thread id. keyword : string, the keyword. activity_id : string, the activity id. debug : boolean, the debug flag """ # # # # # # # # # # # # # # # # # # # # # for tests, disregard tracer if os.getenv('test_mode', None) is not None: return # # # # # # # # # # # # # # # # # # # # if jrds_client is None or locallogger.default_logger is None: init() if debug and not configuration.get_debug_traces(): return if task_name.startswith("log"): task_name = "_".join(task_name.split("_")[1:]) task_name = task_name.title().replace("_", "") if isinstance(message, dict): message = dict_to_str(message) if activity_id is None: activity_id = u_activity_id # local trace # we prioritize cloud traces, do not raise exception if local tracing raises an exception locallogger.log_info(message) # MDS if not debug: format_and_issue_generic_hybrid_worker_trace(event_id, task_name, message, t_id, keyword, activity_id)
def trace_generic_hybrid_worker_event(event_id, task_name, message, t_id, keyword, debug=False): """Write the trace to STDOUT / log file (on disk) / to MDS (in the cloud). Note: This method run in a background thread. Args: event_id : int , the event id. This event id doesn't have to map to an ETW event id in the cloud. task_name : string, the task name. message : string, the message. t_id : int , the thread id. keyword : string, the keyword. """ # # # # # # # # # # # # # # # # # # # # # for tests, disregard tracer if os.getenv('test_mode', None) is not None: return # # # # # # # # # # # # # # # # # # # # if jrds_client is None or default_logger is None: init() if debug and not configuration.get_debug_traces(): return if task_name.startswith("log"): task_name = "_".join(task_name.split("_")[1:]) task_name = task_name.title().replace("_", "") if isinstance(message, dict): message = dict_to_str(message) # local trace # we prioritize cloud traces, do not raise exception if local tracing raises an exception try: default_logger.info(message) except Exception, e: print str(e) pass
def trace(event_id, task_name, message, t_id, keyword, debug=False): """Write the trace to STDOUT / log file (on disk) / to MDS (in the cloud). Note: This method run in a background thread. Args: event_id : int , the event id. This event id doesn't have to map to an ETW event id in the cloud. task_name : string, the task name. message : string, the message. t_id : int , the thread id. keyword : string, the keyword. """ # # # # # # # # # # # # # # # # # # # # # for tests, disregard tracer if os.getenv('test_mode', None) is not None: return # # # # # # # # # # # # # # # # # # # # if jrds_client is None or default_logger is None: init() if debug and not configuration.get_debug_traces(): return if task_name.startswith("log"): task_name = "_".join(task_name.split("_")[1:]) task_name = task_name.title().replace("_", "") if isinstance(message, dict): message = dict_to_str(message) # local trace default_logger.info(message) # MDS if not debug: issue_jrds_trace(event_id, task_name, message, t_id, keyword)