def _get_valid_trace_context(trace_context):
 assert isinstance(trace_context, (TraceContext, dict))
 if isinstance(trace_context, dict):
  trace_context = TraceContext(**trace_context)
 return trace_context

def _get_valid_trace_context ( trace_context ) : assert isinstance ( trace_context , ( TraceContext , dict ) ) if isinstance ( trace_context , dict ) : trace_context = TraceContext ( ** trace_context ) return trace_context
check if tarce_context is a valid type and returns a tracecontext object .