I would check for invalid span in the trace ( I presume a trace is a sequence of spans, and if any one of those spans is invalid, then the trace addition is invalid as well ?) before proceeding with the addition.