diff --git a/parse.go b/parse.go index 4bb417a..d3337d8 100644 --- a/parse.go +++ b/parse.go @@ -42,6 +42,8 @@ type Transaction struct { Size int `json:"size"` RowsCount int `json:"rowsCount"` Status uint8 `json:"status"` + TxStartTime int64 `json:"txStartTime"` + TxEndTime int64 `json:"txEndTime"` sqlOrigin []string `json:"sqlOrigin"` Txs []TxDetail `json:"txs"` validSchemaCount int @@ -611,11 +613,16 @@ func parseBinlogWithFilter(r io.Reader, parse *replication.BinlogParser, filter if ev.Type == "query" { switch strings.ToLower(ev.Data) { case "begin": + if tx.TxStartTime == 0 { + tx.TxStartTime = int64(h.Timestamp) + } status = STATUS_BEGIN case "commit": status = STATUS_COMMIT + tx.TxEndTime = int64(h.Timestamp) case "rollback": status = STATUS_ROLLBACK + tx.TxEndTime = int64(h.Timestamp) } tx.Status = status }