Skip to content

Commit

Permalink
add AddCallerSkip and account for fetcher cancel logs
Browse files Browse the repository at this point in the history
  • Loading branch information
orouz committed Jan 22, 2025
1 parent e8a9105 commit a2d988f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/resources/fetching/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (m *Manager) fetchSingle(ctx context.Context, k string, cycleMetadata cycle
case context.DeadlineExceeded:
return fmt.Errorf("fetcher %s reached a timeout after %v seconds", k, m.timeout.Seconds())
case context.Canceled:
return fmt.Errorf("fetcher %s was canceled", k)
return fmt.Errorf("fetcher %s %s", k, ctx.Err().Error())
default:
return fmt.Errorf("fetcher %s failed with an unknown error: %v", k, ctx.Err())
}
Expand Down
2 changes: 2 additions & 0 deletions internal/resources/utils/clog/clog.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"strings"

"github.com/elastic/elastic-agent-libs/logp"
"go.uber.org/zap"
)

type Logger struct {
Expand Down Expand Up @@ -50,6 +51,7 @@ func (l *Logger) With(args ...any) *Logger {
}

func NewLogger(selector string, options ...logp.LogOption) *Logger {
options = append(options, zap.AddCallerSkip(1))
logger := logp.NewLogger(selector).WithOptions(options...)
return &Logger{logger}
}
Expand Down

0 comments on commit a2d988f

Please sign in to comment.