Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
27 changes: 27 additions & 0 deletions .chloggen/mute-log.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: pkg/stanza/fileconsumer

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Mute new reader log when the noStateTracker is used

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [39855]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
7 changes: 6 additions & 1 deletion pkg/stanza/fileconsumer/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,13 @@ func (m *Manager) newReader(ctx context.Context, file *os.File, fp *fingerprint.
return r, nil
}

// When the NoStateTracker is used, this would result in log spam as new
// readers are created every scrape interval.
if m.tracker.Name() != tracker.NoStateTracker {
m.set.Logger.Info("Started watching file", zap.String("path", file.Name()))
}

// If we don't match any previously known files, create a new reader from scratch
m.set.Logger.Info("Started watching file", zap.String("path", file.Name()))
r, err := m.readerFactory.NewReader(file, fp)
if err != nil {
return nil, err
Expand Down
14 changes: 14 additions & 0 deletions pkg/stanza/fileconsumer/internal/tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator"
)

const (
FileTracker = "fileTracker"
NoStateTracker = "noStateTracker"
)

// Interface for tracking files that are being consumed.
type Tracker interface {
Name() string
Add(reader *reader.Reader)
GetCurrentFile(fp *fingerprint.Fingerprint) *reader.Reader
GetOpenFile(fp *fingerprint.Fingerprint) *reader.Reader
Expand Down Expand Up @@ -63,6 +69,10 @@ func NewFileTracker(ctx context.Context, set component.TelemetrySettings, maxBat
return t
}

func (t *fileTracker) Name() string {
return FileTracker
}

func (t *fileTracker) Add(reader *reader.Reader) {
// add a new reader for tracking
t.currentPollFiles.Add(reader)
Expand Down Expand Up @@ -155,6 +165,10 @@ func NewNoStateTracker(set component.TelemetrySettings, maxBatchFiles int) Track
}
}

func (t *noStateTracker) Name() string {
return NoStateTracker
}

func (t *noStateTracker) Add(reader *reader.Reader) {
// add a new reader for tracking
t.currentPollFiles.Add(reader)
Expand Down
Loading