Skip to content

[receiver/filelog] names of files are printed repeatedly to stdout #39414

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

Closed
andrzej-stencel opened this issue Apr 15, 2025 · 1 comment · Fixed by #39413 or microsoft/azl-otel-collector#9
Assignees
Labels
bug Something isn't working receiver/filelog

Comments

@andrzej-stencel
Copy link
Member

andrzej-stencel commented Apr 15, 2025

Component(s)

receiver/filelog

What happened?

When using the File Log receiver in v0.124.0, the collector prints out to stdout each tracked file's name, on every poll interval (200ms by default). This means that if the File Log receiver is tracking 3 files, 3 * 5 = 15 lines containing the names of the files will be printed to stdout every second (5 lines for each file).

Steps to Reproduce

  1. Run collector with the below config

Expected Result

File names "logs.log", "logs.json", "logs.txt" are not printed to console output.

Actual Result

File names "logs.log", "logs.json", "logs.txt" are printed to console output on every poll (200ms by default).

Collector version

v0.124.0

OpenTelemetry Collector configuration

service:
  pipelines:
    logs:
      receivers:
        - filelog
      exporters:
        - debug
receivers:
  filelog:
    include:
      - logs.*
    exclude:
      - logs.tgz
    start_at: beginning
exporters:
  debug:

Log output

$ otelcol-contrib-0.124.0-linux_amd64 --config 0415-filelog-receiver-bug.yaml
2025-04-15T12:40:05.099+0200    info    [email protected]/service.go:199 Setting up own telemetry...
2025-04-15T12:40:05.099+0200    info    builders/builders.go:26 Development component. May change in the future.
2025-04-15T12:40:05.100+0200    info    [email protected]/service.go:266 Starting otelcol-contrib...     {"Version": "0.124.0", "NumCPU": 20}
2025-04-15T12:40:05.101+0200    info    extensions/extensions.go:41     Starting extensions...
2025-04-15T12:40:05.101+0200    info    adapter/receiver.go:41  Starting stanza receiver
2025-04-15T12:40:05.101+0200    info    [email protected]/service.go:289 Everything is ready. Begin running and processing data.
2025-04-15T12:40:05.303+0200    info    fileconsumer/file.go:265        Started watching file   {"component": "fileconsumer", "path": "logs.json"}
2025-04-15T12:40:05.303+0200    info    fileconsumer/file.go:265        Started watching file   {"component": "fileconsumer", "path": "logs.log"}
2025-04-15T12:40:05.303+0200    info    fileconsumer/file.go:265        Started watching file   {"component": "fileconsumer", "path": "logs.txt"}
logs.txt
logs.json
logs.log
2025-04-15T12:40:05.401+0200    info    Logs    {"resource logs": 1, "log records": 8}
logs.txt
logs.log
logs.json
logs.txt
logs.log
logs.json
logs.txt
logs.log
logs.json
logs.txt
logs.json
logs.log
logs.txt
logs.log
logs.json
logs.txt
logs.json
logs.log
logs.txt
logs.json
logs.log
logs.txt
logs.json
logs.log

Additional context

Caused by this line: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.124.0/pkg/stanza/fileconsumer/internal/reader/reader.go#L185

Introduced in #39373.

Workaround

The file names are printed to stdout and the collector's logs are printed to stderr by default. This means redirecting stdout is a workaround:

$ otelcol-contrib-0.124.0-linux_amd64 --config 0415-filelog-receiver-bug.yaml > /dev/null
2025-04-15T12:40:54.523+0200    info    [email protected]/service.go:199 Setting up own telemetry...
2025-04-15T12:40:54.523+0200    info    builders/builders.go:26 Development component. May change in the future.
2025-04-15T12:40:54.524+0200    info    [email protected]/service.go:266 Starting otelcol-contrib...     {"Version": "0.124.0", "NumCPU": 20}
2025-04-15T12:40:54.524+0200    info    extensions/extensions.go:41     Starting extensions...
2025-04-15T12:40:54.524+0200    info    adapter/receiver.go:41  Starting stanza receiver
2025-04-15T12:40:54.525+0200    info    [email protected]/service.go:289 Everything is ready. Begin running and processing data.
2025-04-15T12:40:54.726+0200    info    fileconsumer/file.go:265        Started watching file   {"component": "fileconsumer", "path": "logs.json"}
2025-04-15T12:40:54.727+0200    info    fileconsumer/file.go:265        Started watching file   {"component": "fileconsumer", "path": "logs.log"}
2025-04-15T12:40:54.727+0200    info    fileconsumer/file.go:265        Started watching file   {"component": "fileconsumer", "path": "logs.txt"}
2025-04-15T12:40:54.826+0200    info    Logs    {"resource logs": 1, "log records": 8}
@andrzej-stencel andrzej-stencel added bug Something isn't working needs triage New item requiring triage labels Apr 15, 2025
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@andrzej-stencel andrzej-stencel removed the needs triage New item requiring triage label Apr 15, 2025
@andrzej-stencel andrzej-stencel self-assigned this Apr 15, 2025
@andrzej-stencel andrzej-stencel changed the title [receiver/filelog] names of files are printed to stdout [receiver/filelog] names of files are printed repeatedly to stdout Apr 15, 2025
atoulme pushed a commit to atoulme/opentelemetry-collector-contrib that referenced this issue Apr 15, 2025
atoulme added a commit that referenced this issue Apr 15, 2025
Fixes
#39414.

This applies the fix to the release branch in preparation of 0.124.1.

Co-authored-by: Andrzej Stencel <[email protected]>
akshays-19 pushed a commit to akshays-19/opentelemetry-collector-contrib that referenced this issue Apr 23, 2025
basti1302 added a commit to dash0hq/dash0-operator that referenced this issue Apr 24, 2025
basti1302 added a commit to dash0hq/dash0-operator that referenced this issue Apr 24, 2025
Fiery-Fenix pushed a commit to Fiery-Fenix/opentelemetry-collector-contrib that referenced this issue Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment