MCPcopy Create free account
hub / github.com/StackStorm/st2 / _get_valid_trace_context

Function _get_valid_trace_context

st2common/st2common/services/trace.py:55–70  ·  view source on GitHub ↗

Check if tarce_context is a valid type and returns a TraceContext object.

(trace_context)

Source from the content-addressed store, hash-verified

53
54
55def _get_valid_trace_context(trace_context):
56 """
57 Check if tarce_context is a valid type and returns a TraceContext object.
58 """
59 if not isinstance(trace_context, (TraceContext, dict)):
60 raise TypeError(
61 "The trace context has a value that is not a dictionary"
62 f" (was {type(trace_context)})."
63 )
64
65 # Pretty much abuse the dynamic nature of python to make it possible to support
66 # both dict and TraceContext types.
67 if isinstance(trace_context, dict):
68 trace_context = TraceContext(**trace_context)
69
70 return trace_context
71
72
73def _get_single_trace_by_component(**component_filter):

Callers 3

get_traceFunction · 0.85

Calls 1

TraceContextClass · 0.90

Tested by

no test coverage detected