Check if tarce_context is a valid type and returns a TraceContext object.
(trace_context)
| 53 | |
| 54 | |
| 55 | def _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 | |
| 73 | def _get_single_trace_by_component(**component_filter): |
no test coverage detected