remove timing debug
This commit is contained in:
parent
7a00123ed0
commit
662764929d
|
@ -48,7 +48,6 @@ func PushAlerts(alerts []types.RuntimeAlert, client *apiclient.ApiClient) error
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
alertsToPush, err := dedupAlerts(alerts)
|
alertsToPush, err := dedupAlerts(alerts)
|
||||||
|
|
||||||
start := time.Now()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to transform alerts for api")
|
return errors.Wrap(err, "failed to transform alerts for api")
|
||||||
}
|
}
|
||||||
|
@ -56,7 +55,6 @@ func PushAlerts(alerts []types.RuntimeAlert, client *apiclient.ApiClient) error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed sending alert to LAPI")
|
return errors.Wrap(err, "failed sending alert to LAPI")
|
||||||
}
|
}
|
||||||
log.Tracef("sent %d alerts in %s", len(alertsToPush), time.Since(start))
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,6 @@ func (c *Controller) sendAlertToPluginChannel(alert *models.Alert, profileID uin
|
||||||
|
|
||||||
// CreateAlert : write received alerts in body to the database
|
// CreateAlert : write received alerts in body to the database
|
||||||
func (c *Controller) CreateAlert(gctx *gin.Context) {
|
func (c *Controller) CreateAlert(gctx *gin.Context) {
|
||||||
|
|
||||||
startCreateAlert := time.Now()
|
|
||||||
var input models.AddAlertsRequest
|
var input models.AddAlertsRequest
|
||||||
|
|
||||||
claims := jwt.ExtractClaims(gctx)
|
claims := jwt.ExtractClaims(gctx)
|
||||||
|
@ -131,7 +129,6 @@ func (c *Controller) CreateAlert(gctx *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
stopFlush := false
|
stopFlush := false
|
||||||
startAlertLoop := time.Now()
|
|
||||||
for _, alert := range input {
|
for _, alert := range input {
|
||||||
alert.MachineID = machineID
|
alert.MachineID = machineID
|
||||||
if len(alert.Decisions) != 0 {
|
if len(alert.Decisions) != 0 {
|
||||||
|
@ -177,15 +174,12 @@ func (c *Controller) CreateAlert(gctx *gin.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Tracef("alert loop in controller took %s", time.Since(startAlertLoop))
|
|
||||||
|
|
||||||
if stopFlush {
|
if stopFlush {
|
||||||
c.DBClient.CanFlush = false
|
c.DBClient.CanFlush = false
|
||||||
}
|
}
|
||||||
|
|
||||||
startDbCall := time.Now()
|
|
||||||
alerts, err := c.DBClient.CreateAlert(machineID, input)
|
alerts, err := c.DBClient.CreateAlert(machineID, input)
|
||||||
log.Tracef("CreateAlert : %s", time.Since(startDbCall))
|
|
||||||
c.DBClient.CanFlush = true
|
c.DBClient.CanFlush = true
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -202,8 +196,6 @@ func (c *Controller) CreateAlert(gctx *gin.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Tracef("%d alerts created in %s", len(input), time.Since(startCreateAlert))
|
|
||||||
|
|
||||||
gctx.JSON(http.StatusCreated, alerts)
|
gctx.JSON(http.StatusCreated, alerts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -306,7 +306,6 @@ func (c *Client) CreateAlertBulk(machineId string, alertList []*models.Alert) ([
|
||||||
c.Log.Debugf("writing %d items", len(alertList))
|
c.Log.Debugf("writing %d items", len(alertList))
|
||||||
bulk := make([]*ent.AlertCreate, 0, bulkSize)
|
bulk := make([]*ent.AlertCreate, 0, bulkSize)
|
||||||
alertDecisions := make([][]*ent.Decision, 0, bulkSize)
|
alertDecisions := make([][]*ent.Decision, 0, bulkSize)
|
||||||
alertLoopStart := time.Now()
|
|
||||||
for i, alertItem := range alertList {
|
for i, alertItem := range alertList {
|
||||||
var decisions []*ent.Decision
|
var decisions []*ent.Decision
|
||||||
var metas []*ent.Meta
|
var metas []*ent.Meta
|
||||||
|
@ -525,16 +524,12 @@ func (c *Client) CreateAlertBulk(machineId string, alertList []*models.Alert) ([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.Log.Tracef("alert loop took %s for %d elements", time.Since(alertLoopStart), len(alertList))
|
|
||||||
|
|
||||||
createBulkStart := time.Now()
|
|
||||||
alerts, err := c.Ent.Alert.CreateBulk(bulk...).Save(c.CTX)
|
alerts, err := c.Ent.Alert.CreateBulk(bulk...).Save(c.CTX)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []string{}, errors.Wrapf(BulkError, "leftovers creating alert : %s", err)
|
return []string{}, errors.Wrapf(BulkError, "leftovers creating alert : %s", err)
|
||||||
}
|
}
|
||||||
c.Log.Infof("createBulk took %s for %d elements", time.Since(createBulkStart), len(bulk))
|
|
||||||
|
|
||||||
decisionsUpdateTime := time.Now()
|
|
||||||
for alertIndex, a := range alerts {
|
for alertIndex, a := range alerts {
|
||||||
ret = append(ret, strconv.Itoa(a.ID))
|
ret = append(ret, strconv.Itoa(a.ID))
|
||||||
d := alertDecisions[alertIndex]
|
d := alertDecisions[alertIndex]
|
||||||
|
@ -547,8 +542,6 @@ func (c *Client) CreateAlertBulk(machineId string, alertList []*models.Alert) ([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Log.Infof("decisions update took %s for %d elements", time.Since(decisionsUpdateTime), len(alerts))
|
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue