write trace to db