Will update an existing Trace or add a new Trace. This method will only look for exact Trace as identified by the trace_context. Even if the trace_context contain a trace_tag it shall not be used to lookup a Trace. * If an exact matching Trace is not found a new Trace is created
(
trace_context, action_executions=None, rules=None, trigger_instances=None
)
| 209 | |
| 210 | |
| 211 | def add_or_update_given_trace_context( |
| 212 | trace_context, action_executions=None, rules=None, trigger_instances=None |
| 213 | ): |
| 214 | """ |
| 215 | Will update an existing Trace or add a new Trace. This method will only look for exact |
| 216 | Trace as identified by the trace_context. Even if the trace_context contain a trace_tag |
| 217 | it shall not be used to lookup a Trace. |
| 218 | |
| 219 | * If an exact matching Trace is not found a new Trace is created |
| 220 | * Whenever only a trace_tag is supplied a new Trace is created. |
| 221 | |
| 222 | :param trace_context: context object using which a trace can be found. If not found |
| 223 | trace_context.trace_tag is used to start new trace. |
| 224 | :type trace_context: ``dict`` or ``TraceContext`` |
| 225 | |
| 226 | :param action_executions: The action_execution to be added to the Trace. Should a list |
| 227 | of object_ids or a dict containing object_ids and caused_by. |
| 228 | :type action_executions: ``list`` |
| 229 | |
| 230 | :param rules: The rules to be added to the Trace. Should a list of object_ids or a dict |
| 231 | containing object_ids and caused_by. |
| 232 | :type rules: ``list`` |
| 233 | |
| 234 | :param trigger_instances: The trigger_instances to be added to the Trace. Should a list |
| 235 | of object_ids or a dict containing object_ids and caused_by. |
| 236 | :type trigger_instances: ``list`` |
| 237 | |
| 238 | :rtype: ``TraceDB`` |
| 239 | """ |
| 240 | trace_db = get_trace(trace_context=trace_context, ignore_trace_tag=True) |
| 241 | if not trace_db: |
| 242 | # since trace_db is None need to end up with a valid trace_context |
| 243 | trace_context = _get_valid_trace_context(trace_context) |
| 244 | trace_db = TraceDB(trace_tag=trace_context.trace_tag) |
| 245 | return add_or_update_given_trace_db( |
| 246 | trace_db=trace_db, |
| 247 | action_executions=action_executions, |
| 248 | rules=rules, |
| 249 | trigger_instances=trigger_instances, |
| 250 | ) |
| 251 | |
| 252 | |
| 253 | def add_or_update_given_trace_db( |
nothing calls this directly
no test coverage detected