Skip to content

Commit

Permalink
cleanup logs
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Nov 6, 2024
1 parent 17de402 commit dcad89b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion internal/pkg/api/handleCheckin.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func (ct *CheckinT) ProcessRequest(zlog zerolog.Logger, w http.ResponseWriter, r
actions = append(actions, *actionResp)
break LOOP
case <-longPoll.C:
zlog.Trace().Str(logger.AgentID, agent.Id).Msg("fire long poll")
zlog.Trace().Msg("fire long poll")
break LOOP
case <-tick.C:
err := ct.bc.CheckIn(agent.Id, string(req.Status), req.Message, nil, rawComponents, nil, ver, unhealthyReason, false)
Expand Down
8 changes: 4 additions & 4 deletions internal/pkg/bulk/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func (b *Bulker) Run(ctx context.Context) error {
}

case <-timer.C:
zerolog.Ctx(ctx).Debug().
zerolog.Ctx(ctx).Trace().
Str("mod", kModBulk).
Int("itemCnt", itemCnt).
Int("byteCnt", byteCnt).
Expand Down Expand Up @@ -443,7 +443,7 @@ func (b *Bulker) Run(ctx context.Context) error {

func (b *Bulker) flushQueue(ctx context.Context, w *semaphore.Weighted, queue queueT) error {
start := time.Now()
zerolog.Ctx(ctx).Debug().
zerolog.Ctx(ctx).Trace().
Str("mod", kModBulk).
Int("cnt", queue.cnt).
Int("szPending", queue.pending).
Expand All @@ -455,7 +455,7 @@ func (b *Bulker) flushQueue(ctx context.Context, w *semaphore.Weighted, queue qu
return err
}

zerolog.Ctx(ctx).Debug().
zerolog.Ctx(ctx).Trace().
Str("mod", kModBulk).
Int("cnt", queue.cnt).
Dur("tdiff", time.Since(start)).
Expand Down Expand Up @@ -493,7 +493,7 @@ func (b *Bulker) flushQueue(ctx context.Context, w *semaphore.Weighted, queue qu
apm.CaptureError(ctx, err).Send()
}

zerolog.Ctx(ctx).Debug().
zerolog.Ctx(ctx).Trace().
Err(err).
Str("mod", kModBulk).
Int("cnt", queue.cnt).
Expand Down
5 changes: 2 additions & 3 deletions internal/pkg/bulk/opApiKey.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,10 @@ func (b *Bulker) flushUpdateAPIKey(ctx context.Context, queue queueT) error {
req := &esapi.SecurityBulkUpdateAPIKeysRequest{
Body: bytes.NewReader(payload),
}
zerolog.Ctx(ctx).Debug().Msg("flushUpdateAPIKey: Sending request to Elasticsearch")

res, err := req.Do(ctx, b.es)
if err != nil {
zerolog.Ctx(ctx).Error().Err(err).Msg("flushUpdateAPIKey: Error sending bulk API Key update request to Elasticsearch")
zerolog.Ctx(ctx).Error().Err(err).Msg("Error sending bulk API Key update request to Elasticsearch")
return err
}
if res.Body != nil {
Expand All @@ -229,7 +228,7 @@ func (b *Bulker) flushUpdateAPIKey(ctx context.Context, queue queueT) error {
return parseError(res, zerolog.Ctx(ctx))
}

zerolog.Ctx(ctx).Debug().Strs("IDs", bulkReq.IDs).RawJSON("role", role).Msg("flushUpdateAPIKey: API Keys updated.")
zerolog.Ctx(ctx).Debug().Strs("IDs", bulkReq.IDs).RawJSON("role", role).Msg("API Keys updated.")

responses[responseIdx] = res.StatusCode
for _, id := range idsInBatch {
Expand Down
8 changes: 3 additions & 5 deletions internal/pkg/bulk/opBulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,9 @@ func (b *Bulker) flushBulk(ctx context.Context, queue queueT) error {
req.Refresh = "true"
}

zerolog.Ctx(ctx).Debug().Msg("flushBulk: Sending request to Elasticsearch")

res, err := req.Do(ctx, b.es)
if err != nil {
zerolog.Ctx(ctx).Error().Err(err).Str("mod", kModBulk).Msg("flushBulk: Fail BulkRequest req.Do")
zerolog.Ctx(ctx).Error().Err(err).Str("mod", kModBulk).Msg("Fail BulkRequest req.Do")
return err
}

Expand All @@ -220,7 +218,7 @@ func (b *Bulker) flushBulk(ctx context.Context, queue queueT) error {
}

if res.IsError() {
zerolog.Ctx(ctx).Error().Str("mod", kModBulk).Str("error.message", res.String()).Msg("flushBulk: Fail BulkRequest result")
zerolog.Ctx(ctx).Error().Str("mod", kModBulk).Str("error.message", res.String()).Msg("Fail BulkRequest result")
return parseError(res, zerolog.Ctx(ctx))
}

Expand Down Expand Up @@ -253,7 +251,7 @@ func (b *Bulker) flushBulk(ctx context.Context, queue queueT) error {
zerolog.Ctx(ctx).Debug().Err(errors.New(buf.String())).Msg("Bulk call: Es returned an error")
}

zerolog.Ctx(ctx).Debug().
zerolog.Ctx(ctx).Trace().
Err(err).
Bool("refresh", queue.ty == kQueueRefreshBulk).
Str("mod", kModBulk).
Expand Down
4 changes: 1 addition & 3 deletions internal/pkg/bulk/opRead.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ func (b *Bulker) flushRead(ctx context.Context, queue queueT) error {
req.Refresh = &refresh
}

zerolog.Ctx(ctx).Debug().Msg("flushRead: Sending request to Elasticsearch")

res, err := req.Do(ctx, b.es)

if err != nil {
Expand Down Expand Up @@ -144,7 +142,7 @@ func (b *Bulker) flushRead(ctx context.Context, queue queueT) error {
return err
}

zerolog.Ctx(ctx).Debug().
zerolog.Ctx(ctx).Trace().
Err(err).
Bool("refresh", refresh).
Str("mod", kModBulk).
Expand Down
4 changes: 1 addition & 3 deletions internal/pkg/bulk/opSearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ func (b *Bulker) flushSearch(ctx context.Context, queue queueT) error {
err error
)

zerolog.Ctx(ctx).Debug().Msg("flushSearch: Sending request to Elasticsearch")

if queue.ty == kQueueFleetSearch {
req := esapi.FleetMsearchRequest{
Body: bytes.NewReader(buf.Bytes()),
Expand Down Expand Up @@ -201,7 +199,7 @@ func (b *Bulker) flushSearch(ctx context.Context, queue queueT) error {
return err
}

zerolog.Ctx(ctx).Debug().
zerolog.Ctx(ctx).Trace().
Err(err).
Str("mod", kModBulk).
Dur("rtt", time.Since(start)).
Expand Down

0 comments on commit dcad89b

Please sign in to comment.