searcher: warn log deadline errors in hybrid search (#58429)

Currently we are spamming sentry. This likely happens when a low search
timeout is set or possibly transiently during a rollout of zoekt.

Test Plan: unit tests will cover if this regresses functionality.
This commit is contained in:
Keegan Carruthers-Smith 2023-11-20 14:42:38 +02:00 committed by GitHub
parent e45c2edb55
commit 57b839bd55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -53,6 +53,9 @@ func (s *Service) hybrid(ctx context.Context, rootLogger log.Logger, p *protocol
// request. As such we centralize our observability to always take into
// account the state of the ctx.
defer func() {
// We can downgrade error logs to rootLogger.Warn
errorLogger := rootLogger.Error
if err != nil {
switch ctx.Err() {
case context.Canceled:
@ -66,11 +69,12 @@ func (s *Service) hybrid(ctx context.Context, rootLogger log.Logger, p *protocol
// path in this case.
recordHybridFinalState("search-timeout")
unsearched, ok = nil, true
errorLogger = rootLogger.Warn
}
}
if err != nil {
rootLogger.Error("hybrid search failed", log.String("state", finalState), log.Error(err))
errorLogger("hybrid search failed", log.String("state", finalState), log.Error(err))
} else {
rootLogger.Debug("hybrid search done", log.String("state", finalState), log.Bool("ok", ok), log.Int("unsearched.len", len(unsearched)))
}

View File

@ -238,7 +238,8 @@ func (s *Service) search(ctx context.Context, p *protocol.Request, sender matchS
unsearched, ok, err := s.hybrid(ctx, logger, p, sender)
if err != nil {
logger.Error("hybrid search failed", log.Error(err))
// error logging is done inside of s.hybrid so we just return
// error here.
return errors.Wrap(err, "hybrid search failed")
}
if !ok {