Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log skipped files on debug level #3383

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ func (e *Engine) scannerWorker(ctx context.Context) {
decodeLatency.WithLabelValues(decoder.Type().String(), chunk.SourceName).Observe(float64(decodeTime))

if decoded == nil {
ctx.Logger().V(4).Info("decoder not applicable for chunk", "decoder", decoder.Type().String(), "chunk", chunk)
ctx.Logger().V(5).Info("decoder not applicable for chunk", "decoder", decoder.Type().String(), "chunk", chunk)
continue
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/handlers/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ func (h *archiveHandler) extractorHandler(archiveChan chan []byte) func(context.
"filename", file.Name(),
"size", file.Size(),
)
lCtx.Logger().V(5).Info("Handling extracted file.")
lCtx.Logger().V(3).Info("Handling extracted file.")

if file.IsDir() || file.LinkTarget != "" {
lCtx.Logger().V(5).Info("skipping directory or symlink")
lCtx.Logger().V(3).Info("skipping directory or symlink")
return nil
}

Expand All @@ -172,13 +172,13 @@ func (h *archiveHandler) extractorHandler(archiveChan chan []byte) func(context.

fileSize := file.Size()
if int(fileSize) > maxSize {
lCtx.Logger().V(3).Info("skipping file due to size", "size", fileSize)
lCtx.Logger().V(2).Info("skipping file: size exceeds max allowed", "size", fileSize, "limit", maxSize)
h.metrics.incFilesSkipped()
return nil
}

if common.SkipFile(file.Name()) || common.IsBinary(file.Name()) {
lCtx.Logger().V(5).Info("skipping file")
lCtx.Logger().V(2).Info("skipping file: extension is ignored")
h.metrics.incFilesSkipped()
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/handlers/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (h *defaultHandler) handleNonArchiveContent(ctx logContext.Context, reader
mimeExt := reader.mimeExt

if common.SkipFile(mimeExt) || common.IsBinary(mimeExt) {
ctx.Logger().V(5).Info("skipping file", "ext", mimeExt)
ctx.Logger().V(2).Info("skipping file: extension is ignored", "ext", mimeExt)
h.metrics.incFilesSkipped()
// Make sure we consume the reader to avoid potentially blocking indefinitely.
_, _ = io.Copy(io.Discard, reader)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sources/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ type chunkProcessingInfo struct {
func (s *Source) processChunk(ctx context.Context, info chunkProcessingInfo, chunksChan chan *sources.Chunk) error {
const filesizeLimitBytes int64 = 50 * 1024 * 1024 // 50MB
if info.size > filesizeLimitBytes {
ctx.Logger().V(4).Info("skipping large file", "file", info.name, "size", info.size)
ctx.Logger().V(2).Info("skipping file: size exceeds max allowed", "file", info.name, "size", info.size, "limit", filesizeLimitBytes)
return nil
}

Expand Down
10 changes: 0 additions & 10 deletions pkg/sources/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"sync/atomic"
"time"

"github.com/go-logr/logr"
"github.com/gobwas/glob"
"github.com/google/go-github/v63/github"
"golang.org/x/exp/rand"
Expand Down Expand Up @@ -726,15 +725,6 @@ func (s *Source) cloneAndScanRepo(ctx context.Context, repoURL string, repoInfo
// TODO: Can this be set once or does it need to be set on every iteration? Is |s.scanOptions| set every clone?
s.setScanOptions(s.conn.Base, s.conn.Head)

// Repo size is not collected for wikis.
var logger logr.Logger
if !strings.HasSuffix(repoURL, ".wiki.git") && repoInfo.size > 0 {
logger = ctx.Logger().WithValues("repo_size_kb", repoInfo.size)
} else {
logger = ctx.Logger()
}
logger.V(2).Info("scanning repo")

start := time.Now()
if err = s.git.ScanRepo(ctx, repo, path, s.scanOptions, reporter); err != nil {
return duration, fmt.Errorf("error scanning repo %s: %w", repoURL, err)
Expand Down
Loading