Compact traces in weighted Sobolev spaces