selinon.trace module

Built-in tracing mechanism.

A list of events that can be traced:

Event Event description Emitter msg_dict.keys()
DISPATCHER_WAKEUP Dispatcher was started and will check flow status. Dispatcher dispatcher_id, state, selective, retry, queue, node_args, flow_name
FLOW_START A new flow is starting, this event is emitted on after DISPATCHER_WAKEUP. Dispatcher dispatcher_id, selective, queue, node_args, flow_name
TASK_SCHEDULE Emitted when a new task is scheduled by dispatcher. Dispatcher countdown, condition_str, task_name, queue, node_args, dispatcher_id, parent, task_id, selective, foreach_str, flow_name, selective_edge
TASK_START Emitted when a task is going to be executed on worker side. Task  
SUBFLOW_SCHEDULE Emitted when a flow is scheduled by dispatcher. Dispatcher  
TASK_END Signalizing end of task execution, task finished successfully. Task  
NODE_SUCCESSFUL Signalizing that a node in flow graph (task or flow) successfully finished. Dispatcher  
TASK_DISCARD_RESULT Signalizing that a task returned a value other than None, but no storage was assigned to task to store result. Task  
TASK_FAILURE Signalizing end of task, task raised an exception, marking task as failed. Task  
TASK_RETRY Signalizing that a task failed by, raising an exception and will be retried. Task  
FLOW_FAILURE Signalization of flow failure, one more nodes in flow graph failed without successful fallback run. Dispatcher  
DISPATCHER_FAILURE This event shouldn’t be normally seen - signalizing error in Selinon. Dispatcher  
NODE_FAILURE Signalization of captured failure of node in task flow graph - flow or task failure. Dispatcher  
FALLBACK_START Fallback for node failures in flow is started to handle node failures. Dispatcher  
DISPATCHER_RETRY Dispatcher finished scheduling new nodes and will retry to check flow status after a while. Dispatcher dispatcher_id, state, selective, retry, queue, node_args, state_dict, flow_name, parent
FLOW_END Flow has successfully ended. Dispatcher  
MIGRATION Flow has migration was done. Dispatcher  
MIGRATION_TAINTED_FLOW Signalization of tainted flow when migration was run. Dispatcher  
MIGRATION_SKEW Flow migration has error - skewed migration. Dispatcher  
STORAGE_CONNECT Given node did not connect to storage yet so a new connection is requested by calling DataStorage.connect() Dispatcher/Task storage_name
STORAGE_DISCONNECT Called when disconnecting from storage by calling DataStorage.disconnect() storage adapter destructor  
STORAGE_RETRIEVE Retrieve task result from storage that was assigned to the task. Dispatcher/Task  
STORAGE_RETRIEVED Requested result of task was retrieved. Dispatcher/Task  
STORAGE_STORE Store result of task in the assigned storage. Task  
STORAGE_STORED The result of task has been stored in the assigned storage. Task  
EDGE_COND_FALSE The condition on edge was evaluated as false so destination nodes will not be scheduled. Dispatcher  
FOREACH_RESULT Reports result of foreach function, based on which N nodes will be scheduled (N is runtime variable) Dispatcher  
NODE_STATE_CACHE_GET Requested state of the node (if the node was successful or failed) from cache. Dispatcher  
NODE_STATE_CACHE_ADD Requested entry in the state cache was not found and the node succeeded so new entry to state is added. Dispatcher  
NODE_STATE_CACHE_MISS Requested entry was not found in state cache. Dispatcher  
NODE_STATE_CACHE_HIT Requested entry was found in the state cache and will be used. Dispatcher  
TASK_RESULT_CACHE_GET Try to hit result cache for cached already requested task result. Dispatcher/Task  
TASK_RESULT_CACHE_ADD Add to result cache result of a task that was requested. Dispatcher/Task  
TASK_RESULT_CACHE_MISS Requested task result was not found in the result cache. Dispatcher/Task  
TASK_RESULT_CACHE_HIT Requested task result was found in the result cache. Dispatcher/Task  
SELECTIVE_OMIT_EDGE Given edge will not be fired as it is not part of direct path to requested tasks on selective run. Dispatcher  
SELECTIVE_OMIT_NODE The desired node will not be scheduled as it is not requested task nor dependency of requested task in selective task runs. Dispatcher  
SELECTIVE_RUN_FUNC Keeps track of results of selective run function on selective task runs. Dispatcher dispatcher_id, parent, selective, node_args, flow_name, result, node_name
SELECTIVE_TASK_REUSE Signalizes reuse of already computed results in selective task runs. Dispatcher  
STORAGE_STORE_ERROR Signalizes storing error information in assigned storage on task failure. Task  
STORAGE_OMIT_STORE_ERROR Signalizes that storing error will not be done - missing storage adapter or store_error() is not implemented. Task  
class selinon.trace.Trace[source]

Bases: object

Trace system flow actions.

DISPATCHER_FAILURE = 11
DISPATCHER_RETRY = 14
DISPATCHER_WAKEUP = 0
EAGER_FAILURE = 49
EDGE_COND_FALSE = 22
FALLBACK_COND_FALSE = 38
FALLBACK_COND_TRUE = 39
FALLBACK_START = 13
FLOW_END = 15
FLOW_FAILURE = 10
FLOW_RETRY = 44
FLOW_START = 1
FOREACH_RESULT = 23
MIGRATION = 45
MIGRATION_ERROR = 48
MIGRATION_SKEW = 46
MIGRATION_TAINTED_FLOW = 47
NODE_FAILURE = 12
NODE_STATE_CACHE_ADD = 25
NODE_STATE_CACHE_GET = 24
NODE_STATE_CACHE_HIT = 27
NODE_STATE_CACHE_ISSUE = 40
NODE_STATE_CACHE_MISS = 26
NODE_SUCCESSFUL = 6
RESULT_BACKEND_ISSUE = 43
SELECTIVE_OMIT_EDGE = 32
SELECTIVE_OMIT_NODE = 33
SELECTIVE_RUN_FUNC = 34
SELECTIVE_TASK_REUSE = 35
STORAGE_CONNECT = 16
STORAGE_DISCONNECT = 17
STORAGE_ISSUE = 42
STORAGE_OMIT_STORE_ERROR = 37
STORAGE_RETRIEVE = 18
STORAGE_RETRIEVED = 19
STORAGE_STORE = 20
STORAGE_STORED = 21
STORAGE_STORE_ERROR = 36
SUBFLOW_SCHEDULE = 4
TASK_DISCARD_RESULT = 7
TASK_END = 5
TASK_FAILURE = 8
TASK_RESULT_CACHE_ADD = 29
TASK_RESULT_CACHE_GET = 28
TASK_RESULT_CACHE_HIT = 31
TASK_RESULT_CACHE_ISSUE = 41
TASK_RESULT_CACHE_MISS = 30
TASK_RETRY = 9
TASK_SCHEDULE = 2
TASK_START = 3
WARN_EVENTS = (12, 7, 9, 8, 10, 37, 40, 41, 42, 43, 44, 46, 48, 49)
classmethod event2str(event)[source]

Translate event to it’s string representation.

Parameters:event – event
Returns:string representation of event
classmethod json_trace_func(event, msg_dict)[source]

Trace by directly printing JSONs to stdout or stderr.

Parameters:
  • event – event that triggered trace point
  • msg_dict – a dict holding additional trace information for event
classmethod log(event, *msg_dict, **msg_dict_kwargs)[source]

Log an event.

Parameters:
  • event – tracing event
  • msg_dict – message to be printed
  • msg_dict_kwargs – kwargs like dictionary for traced details
classmethod logging_trace_func(event, msg_dict, logger=None)[source]

Trace to Python’s logging facilities.

Parameters:
  • event – event that triggered trace point
  • msg_dict – a dict holding additional trace information for event
  • logger – a logger to be used, if None, logger from trace_by_logging will be used
classmethod trace_by_func(func)[source]

Trace by a custom function.

Parameters:func – function with a one single argument
classmethod trace_by_json()[source]

Trace by writing directly JSON trace points.

classmethod trace_by_logging(logger=None)[source]

Trace by using Python’s logging.

Parameters:logger – optional logger that should be used
classmethod trace_by_sentry(dsn)[source]

Trace using Sentry (see https://sentry.io).

Parameters:dsn – data source name for connecting to Sentry