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()
|
||||
alertsToPush, err := dedupAlerts(alerts)
|
||||
|
||||
start := time.Now()
|
||||
if err != nil {
|
||||
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 {
|
||||
return errors.Wrap(err, "failed sending alert to LAPI")
|
||||
}
|
||||
log.Tracef("sent %d alerts in %s", len(alertsToPush), time.Since(start))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -114,8 +114,6 @@ func (c *Controller) sendAlertToPluginChannel(alert *models.Alert, profileID uin
|
|||
|
||||
// CreateAlert : write received alerts in body to the database
|
||||
func (c *Controller) CreateAlert(gctx *gin.Context) {
|
||||
|
||||
startCreateAlert := time.Now()
|
||||
var input models.AddAlertsRequest
|
||||
|
||||
claims := jwt.ExtractClaims(gctx)
|
||||
|
@ -131,7 +129,6 @@ func (c *Controller) CreateAlert(gctx *gin.Context) {
|
|||
return
|
||||
}
|
||||
stopFlush := false
|
||||
startAlertLoop := time.Now()
|
||||
for _, alert := range input {
|
||||
alert.MachineID = machineID
|
||||
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 {
|
||||
c.DBClient.CanFlush = false
|
||||
}
|
||||
|
||||
startDbCall := time.Now()
|
||||
alerts, err := c.DBClient.CreateAlert(machineID, input)
|
||||
log.Tracef("CreateAlert : %s", time.Since(startDbCall))
|
||||
c.DBClient.CanFlush = true
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -306,7 +306,6 @@ func (c *Client) CreateAlertBulk(machineId string, alertList []*models.Alert) ([
|
|||
c.Log.Debugf("writing %d items", len(alertList))
|
||||
bulk := make([]*ent.AlertCreate, 0, bulkSize)
|
||||
alertDecisions := make([][]*ent.Decision, 0, bulkSize)
|
||||
alertLoopStart := time.Now()
|
||||
for i, alertItem := range alertList {
|
||||
var decisions []*ent.Decision
|
||||
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)
|
||||
if err != nil {
|
||||
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 {
|
||||
ret = append(ret, strconv.Itoa(a.ID))
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue