insert the metrics inside a transaction