func (mysql *Mysql) receivedMysqlResponse(msg *MysqlMessage) { tuple := msg.TcpTuple trans := mysql.transactionsMap[tuple.Hashable()] if trans == nil { logp.Warn("Response from unknown transaction. Ignoring.") return } // check if the request was received if trans.Mysql == nil { logp.Warn("Response from unknown transaction. Ignoring.") return } // save json details trans.Mysql.Update(common.MapStr{ "affected_rows": msg.AffectedRows, "insert_id": msg.InsertId, "num_rows": msg.NumberOfRows, "num_fields": msg.NumberOfFields, "iserror": msg.IsError, "error_code": msg.ErrorCode, "error_message": msg.ErrorInfo, }) trans.BytesOut = msg.Size trans.Path = msg.Tables trans.ResponseTime = int32(msg.Ts.Sub(trans.ts).Nanoseconds() / 1e6) // resp_time in milliseconds // save Raw message if len(msg.Raw) > 0 { fields, rows := mysql.parseMysqlResponse(msg.Raw) trans.Response_raw = common.DumpInCSVFormat(fields, rows) } trans.Notes = append(trans.Notes, msg.Notes...) mysql.publishTransaction(trans) logp.Debug("mysql", "Mysql transaction completed: %s", trans.Mysql) logp.Debug("mysql", "%s", trans.Response_raw) trans.Notes = append(trans.Notes, msg.Notes...) // remove from map delete(mysql.transactionsMap, trans.tuple.Hashable()) if trans.timer != nil { trans.timer.Stop() } }
func (pgsql *Pgsql) receivedPgsqlResponse(msg *PgsqlMessage) { tuple := msg.TcpTuple transList := pgsql.getTransaction(tuple.Hashable()) if transList == nil || len(transList) == 0 { logp.Warn("Response from unknown transaction. Ignoring.") return } // extract the first transaction from the array trans := pgsql.removeTransaction(transList, tuple, 0) // check if the request was received if trans.Pgsql == nil { logp.Warn("Response from unknown transaction. Ignoring.") return } trans.Pgsql.Update(common.MapStr{ "iserror": msg.IsError, "num_rows": msg.NumberOfRows, "num_fields": msg.NumberOfFields, "error_code": msg.ErrorCode, "error_message": msg.ErrorInfo, "error_severity": msg.ErrorSeverity, }) trans.BytesOut = msg.Size trans.ResponseTime = int32(msg.Ts.Sub(trans.ts).Nanoseconds() / 1e6) // resp_time in milliseconds trans.Response_raw = common.DumpInCSVFormat(msg.Fields, msg.Rows) trans.Notes = append(trans.Notes, msg.Notes...) pgsql.publishTransaction(trans) logp.Debug("pgsql", "Postgres transaction completed: %s\n%s", trans.Pgsql, trans.Response_raw) }